excel - Macro to select first non-empty cell in entire sheet -


suppose there 1 non-empty cell in sheet , want macro find it. far have following code struggling adjust searches columns, not one:

sub firstnonempty()  dim ws worksheet  set ws = activesheet      each cell in ws.columns(1).cells         if not isempty(cell) = true cell.select: exit     next cell end sub 

perhaps there way use variable equal columns instead of "1" in "ws.columns(1).cells"?

you can change for statement to:

for each cell in ws.usedrange.cells 

which has benefit of not scanning rows/columns @ end of worksheet well.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

Python Tornado package error when running server -