Is Active Cell in a Range?

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

I want to write some code like,

If Activecell is part of range whatever then
if true....
else
If fales....
End if

How do I say that?
 
If intersect(activecell, range("a1:b99")) is nothing then
msgbox "not in a1:b99
else
msbox "yes, I am!"
end if
 
how 'bout.........

Sub wheres_cell()

Dim myRange As Range
Dim c As Range

Set myRange = Range("c2:c7")

For Each c In myRange
If ActiveCell.Address = c.Address Then
MsgBox "I'm in the range :) " & c.Address
Exit Sub
Else
'do nothing
End If
Next c

MsgBox "I'm not in the range :("

End Sub


works for me. change to fit your ranges.
susan
 
Back
Top