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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -