Monday, 15 June 2015

vba - Offset Until An Empty CellIs Found -



vba - Offset Until An Empty CellIs Found -

i have column consisting of various names. trying figure out how re-create selected item first empty cell in column f. i've done far:

sub copyfill() if range("f3") = empty activecell.copy range("f3") elseif range("f3") <> empty activecell.copy range("f3").offset(1, 0) end if end sub

but thing can't understand how apply dountil function here in order maintain offsetting until find empty cell excel populate current selection.

thank much in advance time , attention.

p.s. using f3 because column starts me in file.

the efficient way accomplish want next line of code:

activecell.copy range("f:f").find(what:="", after:=range("f3"), lookin:=xlformulas, lookat _ :=xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, matchcase:= _ false, searchformat:=false)

the .find need.

if want loop manually (which much slower), can utilize code:

sub copyfill() dim rng range set rng = range("f3") while rng.value "" set rng = rng.offset(1) wend activecell.copy rng end sub

instead of while status ... wend can utilize do while status ... loop or do until not status ... loop.

vba

No comments:

Post a Comment