Cell in Range Testing Function

  • Thread starter Thread starter Jim C.
  • Start date Start date
J

Jim C.

Can anyone point me to a function that will return a value base on
whether a range of cells is;
1. Located inside another specified range.
2. Intersects another specified Range.
3. Does not intersect another specified range

The function I am looking for would include the ranges in the call
arguments. If I could be so bold I would prefer that this function
support multiple areas as well ( Oh yea, now I'm asking for it.)

I could code this myself, but like the rest of us I'm lazy.

Thanks everyone,

Jim C.
 
The Intersect Method does this:

Sub isect()
Dim rng1 As Range
Dim rng2 As Range
Set rng1 = Range("A1:D2")
Set rng2 = Range("D3")
If Not Application.Intersect(rng1, rng2) Is Nothing Then
'They intersect
MsgBox rng1.Address & " intersects " & rng2.Address
Else
MsgBox rng1.Address & " does not intersect " & rng2.Address
End If
End Sub

This works with contiguous or non-contiguous ranges.

Hth,
Tim

Jim C. said:
Can anyone point me to a function that will return a value base on
whether a range of cells is;
1. Located inside another specified range.
2. Intersects another specified Range.
3. Does not intersect another specified range

The function I am looking for would include the ranges in the call
arguments. If I could be so bold I would prefer that this function
support multiple areas as well ( Oh yea, now I'm asking for it.)

I could code this myself, but like the rest of us I'm lazy.

Thanks everyone,

Jim C.


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
You are most welcome. Glad to help.
Tim

Jim C. said:
Tim:

Haven't had a chance to try this solution out, but it looks quite
eloquent.

Thanks for saving me a great deal of difficult coding time, I was
going to choose another more arduous route.

I knew someone out there would know what I'm doing. Thanks again for
such a tidy solution.

Jim C.



Regards,

Jim C.
Using MS Office 97


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top