Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / July 2007

Tip: Looking for answers? Try searching our database.

Get the Intersection range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Venkat - 12 Jul 2007 16:56 GMT
Hi,

I have two excel range objects. I want to know whether these are intersected
or not. If they are intersected then i need the intersected range or the
starting cell and ending cell of intersected range.

Can any one help me?

Cheers,
Srikanth
Wigi - 12 Jul 2007 18:30 GMT
Hi

Dim rng1 As Range
   Dim rng2 As Range
   Dim inters As Range
   
   Set inters = Application.Intersect(rng1, rng2)
   
   If Not inters Is Nothing Then
       'code
   Else
       'other code
   End If

Signature

Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music

> Hi,
>
[quoted text clipped - 6 lines]
> Cheers,
> Srikanth
Ron Coderre - 12 Jul 2007 18:32 GMT
Here's something to get you started.....

This SUB returns the intersection of the current selection and a range
named: "MyRange"

'---------Start of code-------
Sub GetIntersect()
Dim rRng As Range

Set rRng = Intersect(Selection, Range("MyRange"))
If Not rRng Is Nothing Then
  MsgBox rRng.Address
Else
  MsgBox "No intersection"
End If
End Sub
'---------End of code-------

Is that something you can work with?

(Post back if you have more questions)
***********
Regards,
Ron

XL2002, WinXP

> Hi,
>
[quoted text clipped - 6 lines]
> Cheers,
> Srikanth
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.