need to reference a cell from a changing range

L

Louie

In a worksheet each month results change the amount of rows in column 'B'.
Jan ends at B24, Feb at B32 and so on. From the last cell in column 'B' I
want to move one cell down and one cell to the left (Jan to A25, Feb to A33)
but I don't know the VBA code to do this.
 
J

JLGWhiz

First, get the last row number for column B.
Dim lastRow As Long
lastRow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row

Then to get the cell down 1 and left 1.

Set myRange = Cells(lastRow +1, 1) 'The cell in Col A

Put it in a procedure:

Sub getmyRange()
Dim lastRow As Long
lastRow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
Set myRange = Cells(lastRow +1, 1) 'The cell in Col A
MsgBox myRange.Address
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top