Determining Cell within Range

  • Thread starter Thread starter Pablo
  • Start date Start date
P

Pablo

I am needing to determine if a selected cell is within a certain range. Below
is something that I have tried, but it only returns a 400 error.

Sub FindRange()
Dim rngMyRange As Range

Set rngMyRange = Worksheets("Sheet1").Range(A1, G20)

If ActiveCell.Select = rngMyRange Then
MsgBox ("Good Job")
Else
MsgBox ("Out of Bounds")
End If

End Sub
 
hi
you are trying to set the activecell to equal an entire range.
try this
sub FindRange()
Dim rngMyRange As Range
Set rngMyRange = Worksheets("Sheet1").Range("A1:G20")
If Not Application.Intersect(ActiveCell, rngMyRange) Is Nothing Then
MsgBox ("Good Job")
Else
MsgBox ("Out of Bounds")
End If
End Sub

regards
FSt1
 
Back
Top