ActiveCell in a Range?

F

Filo

Hello-
I am trying to program a certain action if the activecell is inside a
certain range, and a different action if it is outside. How can I receive
some signal as to whether the activecell is within a certain range?
Below is a rough code description of what I am trying to do


If activecell is inside Range(A1:E77) then
....
else
.....

Please let me know if you would need more information. Thank you!!
 
R

Ron de Bruin

You can use intersect

If Not Application.Intersect(Range("A1:E77"), ActiveCell) Is Nothing Then
MsgBox "In the range"
Else
MsgBox "not in the range"
End If
 
T

Trevor Shuttleworth

Sub InRange()
If Not Intersect(ActiveCell, Range("A1:E77")) Is Nothing Then
MsgBox "In Range"
End If
End Sub

Regards

Trevor
 
F

Filo

Thank you both! I love this message board.

Ron de Bruin said:
You can use intersect

If Not Application.Intersect(Range("A1:E77"), ActiveCell) Is Nothing Then
MsgBox "In the range"
Else
MsgBox "not in the range"
End If
 
Top