Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spreadsheet ranges

Status
Not open for further replies.

Luis939

MIS
Feb 28, 2003
453
US
I designed my macro so that it works with one workbook and then makes a reference to another workbook to do somework in that, is there a way of not having to declare a range to work on any part of the other workbook. If i declare cellrange and then say
cellrange.offset(4,0) = myvariable

is there then a way to say offset(1,0) from the cell that has myvariable instead of having to reference cellrange again. basically is there somethign that says do whatever with respect to the last cell worked on without it being the activecell, thanks!
 
Hi,

Ranges/cells can be referenced in a great variety of ways, and it depends what you are trying to accomplish.

I often use the workbook.worksheet.Cell(rowNum, colNum) technique. Offset works well too.

If you want to set a new reference point you could use the Set statement.

Why not incriment the offset?


Skip,
Skip@TheOfficeExperts.com
 
Whichever way you go (.Cells or .Offset) be consistent. .Cells is 1-based and .Offset is 0-based.

Also, be aware that .Cells(r,c) will always be a one-cell range, while .Offset(r,c) will be a range with the same shape as the referenced range.

So, for example, if you Set rng=Range("A1:C3"), then rng.Cells(1,1) will be equivalent to the cell "A1" and rng.Offset(1,1) will be equivalent to the range "B2:D4"


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top