ActiveCell in a Range?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!!
 
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
 
Sub InRange()
If Not Intersect(ActiveCell, Range("A1:E77")) Is Nothing Then
MsgBox "In Range"
End If
End Sub

Regards

Trevor
 
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
 

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