Forum Discussion
INRIM
Dec 27, 2020Copper Contributor
Adrees to the column/row end
I would like to form an address from a cell to the end of its column or row, for instance in a total on the top of a column whose extension covers the column below in full. This is different from a f...
HansVogelaar
Dec 27, 2020MVP
If there are no blank cells between A5 and the last used cell in column A, you can use
=OFFSET($A$5, 0, 0, COUNTA($A$5:$A$1048576), 1)
to refer to the range from A5 to the last used cell in column A.
In VBA, you can use code like this:
Dim LastRow As Long
Dim RangeA As Range
LastRow = Range("A" & Rows.Count).End(xlUp).Row
If LastRow < 5 Then LastRow = 5
Set RangeA = Range("A5:A" & LastRow)