ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell in Range Testing Function (https://www.excelbanter.com/excel-programming/272465-cell-range-testing-function.html)

Jim C.[_2_]

Cell in Range Testing Function
 
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 =---

Tim Zych[_2_]

Cell in Range Testing Function
 
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." wrote in message
...
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

=---





Tim Zych[_2_]

Cell in Range Testing Function
 
You are most welcome. Glad to help.
Tim

"Jim C." wrote in message
...
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.

On Wed, 23 Jul 2003 10:42:56 -0700, "Tim Zych"
You said:

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." wrote in message
.. .
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
=---




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

=---






All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com