C Jones
C Jones

Reputation: 135

excel vba last row variable not computing

I am using the lines:

Dim lastrowmonth as Integer, PMARow As Integer
lastRowMonth = Cells(1 & "," & Rows.Count).End(xlUp).Row
Do While PMARow < lastRowMonth + 1

However it keeps telling me that lastRowMonth = 1and as such wont let me access my code, inside the do while. Any advice here as there are 1400 filled cells in column A and ideally I want to move on to changing 1 to a variable to move through other columns.

Any help would be grand!

Upvotes: 0

Views: 58

Answers (2)

simpLE MAn
simpLE MAn

Reputation: 1622

Try this:

lastRowMonth = Cells(Rows.Count,1).End(xlUp).Row

And maybe it would be a good idea to declare lastRowMonth as a Long to be sure because in excel there are more rows than an Integer can take

Upvotes: 2

Netloh
Netloh

Reputation: 4378

You need to change the second line to:

lastRowMonth = Cells(Rows.Count, 1).End(xlUp).Row

Upvotes: 2

Related Questions