bobrossi56
asked on
VBA code to determine last row not working correctly
I have 8 excel files I run this macro against to set a number format. On 7 of the files it works perfect, on one 0f the files it does not work correct. When I step through the macro, the lrow variable says the excel file only has 2 rows, when in actuality it has 80. When I step through the macro with the other 7 files, the lrow variable is correct. Trying to figure out what is different in this one file that would mess up the last row calc.
Dim lrow As Long
lrow = Cells(Cells.Rows.Count, "E").End(xlUp).Row
Range("E3:Q" & lrow).NumberFormat = "#,##0"
thx experts...BobR
Dim lrow As Long
lrow = Cells(Cells.Rows.Count, "E").End(xlUp).Row
Range("E3:Q" & lrow).NumberFormat = "#,##0"
thx experts...BobR
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your code for last row worked, so I will use that from now on...thx
You're welcome. Glad I could help.
"(Excel) speed-up a loop using dichotomic logic"
[ https://www.experts-exchange.com/questions/28203209/Excel-speed-up-a-loop-using-dichotomic-logic.html ]
That references:
"(Excel) reliable way to find the last row with a value, supporting hidden and autofiltered not contiguous rows"
[ https://www.experts-exchange.com/questions/28187684/Excel-reliable-way-to-find-the-last-row-with-a-value-supporting-hidden-and-autofiltered-not-contiguous-rows.html ]