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

The SDK directory does not exist (ubuntu 16.04) (react native) -

python - How to clone or copy a list? -

python - How to use Celery in Tornado with redis as broker and backend? -