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
Post a Comment