Test if Cell is within Range (name)

  • Thread starter Thread starter goepf
  • Start date Start date
G

goepf

I have a dynamic range (meaning the size will change) that is defined
with a name. How can I easily test if an active cell is within that
range?

Thanks,

'expl:

'Range B2:Z15 (name "TESTRANGE")

'ActiveCell D4

'Test if D4 is within "TESTRANGE"
 
If Application.Intersect(Range("TESTRANGE"),Range("D4")) is Nothing then
msgbox "Does not intersect"
Else
msgbox "Intersects"
End If

Bob Umlas
Excel MVP

goepf said:
I have a dynamic range (meaning the size will change) that is defined
with a name. How can I easily test if an active cell is within that
range?

Thanks,

'expl:

'Range B2:Z15 (name "TESTRANGE")

'ActiveCell D4

'Test if D4 is within "TESTRANGE"


------------------------------------------------



~~Now Available: Financial Statements.xls, a step by step guide to
creating financial statements
 
Dim Isect As Range
Set Isect = Application.Intersect(Range1, Range2)
If isect is nothing then
Do this
Else
Do that
End if

Lars Kofod
-----Original Message-----

I have a dynamic range (meaning the size will change) that is defined
with a name. How can I easily test if an active cell is within that
range?

Thanks,

'expl:

'Range B2:Z15 (name "TESTRANGE")

'ActiveCell D4

'Test if D4 is within "TESTRANGE"


------------------------------------------------

~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by
step guide to creating financial statements
 
Back
Top