Excel - finding the last cell in a collumn in VBA
Excel - finding the last cell in a collumn in VBA
(OP)
If you have a collumn where there exists an unknown number of "blanks" short of stepping through each row is there a smart way of finding the last cell with data?
Selection.End(xlDown).Activate
will find the "next" empty cell but if you dont know if thats the "last" blank?
In my case there will only be one blank - but still just testing the next cell seems a bit too "easy" and is not fool proof - if there could be two blanks and the more data.
Best regards
Morten
Selection.End(xlDown).Activate
will find the "next" empty cell but if you dont know if thats the "last" blank?
In my case there will only be one blank - but still just testing the next cell seems a bit too "easy" and is not fool proof - if there could be two blanks and the more data.
Best regards
Morten





RE: Excel - finding the last cell in a collumn in VBA
Cells(65536, Selection.Column).End(xlUp).Activate
-handleman, CSWP (The new, easy test)
RE: Excel - finding the last cell in a collumn in VBA
Best regards
Morten
RE: Excel - finding the last cell in a collumn in VBA
Cells(rows.count, Selection.Column).End(xlUp).Activate
has the very small advantage that you don't have to remember that 65000 number and it will be forward compatible with future versions excel that may be Avogadro's number of rows.
=====================================
Eng-tips forums: The best place on the web for engineering discussions.