Active Cell within a set range


Posted by Raishon on May 31, 2001 2:54 PM

I have a userform that when you click OK it populates the active cell with the value selected. Can someone help me with a code that if the active cell isn't within a certain range of cells than message box
I tried
If Intersect(Range("d10:d29"), ActiveCell) Then
MsgBox "The Active Cell MUST be where you want the Text"
Else
ActiveCell = UserForm1.ListBox1.Value
End If

This works if the active cell is within the range, if the active cell outside of the range I get an error "Object variable not set"

Posted by Russell on May 31, 2001 3:13 PM

Intersect does not return a true/false, it returns a range. Try this:

Dim rng as Range

if If Intersect(Range("d10:d29"), ActiveCell) Is Nothing Then
...
End If

Posted by Russell on May 31, 2001 3:13 PM

Intersect does not return a true/false, it returns a range. Try this:

If Intersect(Range("d10:d29"), ActiveCell) Is Nothing Then
...
End If

-Russell



Posted by Raishon on May 31, 2001 4:17 PM


THANKS SO MUCH!!! THAT WORKED