View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default Is the active cell part of a named range

use the Intersect method

Sub Test()
msgbox IsInRange(Range("B5"),range("Data"))
End Sub

Function IsInRange(test as range, target as range) as Boolean
dim found as range
set found = Intersect(Test,target)
IsInRange = (NOT Found Is Nothing)
End Function

"Virginia" wrote in message
...
how do use VBA to determine whether or not the activecell is part of a
range
named "Data"
i.e., range("Data") spans from A1:J50

how can i return true on
range("B5") is part os range("Data")
TIA.