syntax question
It also depends on where the code is.
An unqualified range (without the ws. stuff) in a general module, will refer to
the activesheet.
An unqualified range in a worksheet module will refer to the sheet that owns the
code.
dim i as range
set ws = worksheets("someothersheet")
'this will always work
set i = ws.Range(ws3.Cells(2, x), ws3.Cells(lRow, x))
'this will cause an error if you're in a worksheet module (not someothersheet,
though):
set i = ws.Range(Cells(2, x), Cells(lRow, x))
=====
To save typing (and easier to understand (for me at least)), I'd use:
dim ws as worksheet
dim i as range
set ws = worksheets("someothersheet")
with ws
set i = .Range(.Cells(2, x), .Cells(lRow, x))
end with
Note the dot's in front of .range and both .cells.
Gary Keramidas wrote:
just wondering if these are functionally the same:
i = Range(ws3.Cells(2, x), ws3.Cells(lRow, x))
i = ws3.Range(Cells(2, x), Cells(lRow, x))
--
Gary
--
Dave Peterson
|