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

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -