Macro code problem

N

Nick

hi everyone,

I have a problem where I have macro code where i want to
refer to a range name but excel won't recognise what i
want it to do unless i put the cell reference in there.
The code is listed below, cell I175 is range named "cash".

by simply subsituting "cash" for $I$175 does not work!

any ideas?

If Target.Address = ("$I$175") Then
If Range("cash").Value <> 1 Then
Range("debt_terms").Select
Selection.EntireRow.Hidden = False

Range("cash").Select

Else
If Range("cash").Value = 1 Then
Range("debt_terms").Select
Selection.EntireRow.Hidden = True

Range("cash").Select

End If
End If
End If

Thank you very much
Cheers
Nick
 
D

Dave Peterson

Maybe:
if target.address = range("cash").address then
or
if intersect(target, range("cash")) is nothing then exit sub
 
D

Don Guillett

try
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$I$175" Then

If Range("cash") <> 1 Then _
Range("debt_terms").EntireRow.Hidden = False

If Range("cash").Value = 1 Then _
Range("debt_terms").EntireRow.Hidden = True

Range("cash").Select

End If
End Sub
===
OR
=====
Sub UseCash()
If Range("cash") <> 1 Then _
Range("debt_terms").EntireRow.Hidden = False

If Range("cash").Value = 1 Then _
Range("debt_terms").EntireRow.Hidden = True

Range("cash").Select
End Sub
=======
 
Top