I have: N = Cells(Rows.Count, "B").End(xlUp).Row
and it returns 1 all the time, when I have a dataset which contains 200k+ rows.
Very odd, as it is only with this workbook, as with another workbook this line works.
Questions:
Any suggestions as to why this occurs? Any possible work around? My current work around is:
Sub Macro2()
Range("B1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
n = ActiveCell.Row
End Sub
I am assuming that you want the code to run in active (selected) sheet. Example:
should work. However I always prefer to specify at least the sheet first, to make sure my code run from anywhere, like:
Example
Multiple ways finding last row