Thread: Intersect
View Single Post
 
Old 07-27-2014, 06:14 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Code:
Sub test()  
If intersect(ActiveCell, Range("A:A,C:C")) Is Nothing Then     
MsgBox "not intersect" 
Else     
MsgBox "intersect" 
End If  End Sub  

Sub test2()  

Dim colA As ListColumn, colC As ListColumn
'''
Set colA = ListObjects("Table1").ListColumns("a").Range 
Set colC = ListObjects("Table1").ListColumns("c").Range 
'''
Dim rng As Range
Set rng = Union(colA,colC)

If intersect(ActiveCell, rng) Is Nothing Then     
MsgBox "not intersect" 
Else     
MsgBox "intersect" 
End If  
End Sub
I've found out that with the use of "Union()" function, Column A and Column C will be treated seperately whilst otherwise, it will be treated like from Column A to Column C (i.e. including Column B).
Reply With Quote