With mybook.Worksheets(1)
Set rngHeader = .Range(.Cells(1, 1), .Cells(10, 1))
Set rngDayhead = .Range(.Cells(1, 3), .Cells(10, 3))
End With
Set rngSource = Union(rngHeader, rngDayhead)
MsgBox rngSource.Columns.Count
The above code pops a msg box with count 1 but actually it should return 2.
Also if the line,
Set rngDayhead = .Range(.Cells(1, 3), .Cells(10, 3))
is replaced with
Set rngDayhead = .Range(.Cells(1, 2), .Cells(10, 2))
then the count comes correctly that is 2.
What i don't understand is why the count is not 2 when a column in between is skipped?
Bookmarks