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