Get the Intersection range

  • Thread starter Thread starter Venkat
  • Start date Start date
V

Venkat

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
 
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
 
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
 
Back
Top