I am trying to copy values from sheet1 to sheet2. The number of rows of sheet1 varies so I need to store it in a variable. I need something like:
Worksheets("Sheet1").Range("A2:Ab").Select
, where "b" is a variable that stores the number of rows in Sheet1.
Thank you.
You can actually store the
UsedRange
of a worksheet. Or just copy to another sheet directly. e.g.To get the last row of a sheet:
EDIT (Getting Last Row from UsedRange's Address):
One way would be to dynamically create the cell name by concatenating your column and row identifiers and then using the Range(Cell1,Cell2) overload, as below: