excel - selecting data cells with data cells under them -
is possible select cells in excel above cells data (the cell below 1 needs selected needs have data)? if every cell in column has data top cell should selected. if there no data cells above or below cell should not selected. thank you
i found macro select data cells in range, possible add if "data below" this? tried, im green vba. thank you.
sub selectnotblackrange() 'update20131220 dim rng range dim workrng range dim outrng range on error resume next xtitleid = "kutoolsforexcel" set workrng = application.selection set workrng = application.inputbox("range", xtitleid, workrng.address, type:=8) each rng in workrng if rng.value <> "" if outrng nothing set outrng = rng else set outrng = union(outrng, rng) end if end if next if not outrng nothing outrng.select end if end sub
here example typical column, column c:
sub cselect() dim kolumn string, n long dim long kolumn = "c" n = cells(rows.count, kolumn).end(xlup).row = 1 n if cells(i, kolumn).value <> "" , cells(i + 1, kolumn).value <> "" cells(i, kolumn).select exit sub end if next end sub
note:
this select first cell meeting selection criteria.
edit#1:
the sub select cells in column meeting criteria:
sub cselectall() dim kolumn string, n long dim long, rng range kolumn = "c" n = cells(rows.count, kolumn).end(xlup).row set rng = nothing = 1 n if cells(i, kolumn).value <> "" , cells(i + 1, kolumn).value <> "" if rng nothing set rng = cells(i, kolumn) else set rng = union(rng, cells(i, kolumn)) end if end if next if rng nothing else rng.select end if end sub
Comments
Post a Comment