VB range name problem!

  • Thread starter Thread starter Nick
  • Start date Start date
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".

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
 
Nick said:
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".

any ideas?

Nick,

Are you saying that you can't substitute $I$175 in the following line with
'cash'?

If Target.Address = ("$I$175") Then

If so, that is because 'cash' refers to a range, whereas this test is on an
address string. If you want to use the range name, do this

If Not Intersect(Target, Range("cash")) Then

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top