Asi
08-16-2010, 05:51 AM
Why ?
if I do
Dim rng As Range
Set rng = Application.Union(Worksheets(SheetName).Range(Cells(r, BCol), Cells(r, ACol)), _
Worksheets(SheetName).Range(Cells(r, ZCol), Cells(r, ECol)))
I get an error:
Application defined or object defined error.
BUT when I do:
Dim rng As Range
With Worksheets(SheetName)
Set rng = Application.Union(.Range(.Cells(r, BCol), .Cells(r, ACol)), .Range(.Cells(r, ZCol), .Cells(r, ECol)))
End With
it works fine.
if I do
Dim rng As Range
Set rng = Application.Union(Worksheets(SheetName).Range(Cells(r, BCol), Cells(r, ACol)), _
Worksheets(SheetName).Range(Cells(r, ZCol), Cells(r, ECol)))
I get an error:
Application defined or object defined error.
BUT when I do:
Dim rng As Range
With Worksheets(SheetName)
Set rng = Application.Union(.Range(.Cells(r, BCol), .Cells(r, ACol)), .Range(.Cells(r, ZCol), .Cells(r, ECol)))
End With
it works fine.