excel - copy cells in a range to a column -


i have myrange = a1:c3

current values in range below:

a1=a, b1=d, c1=f a2=b, b2=e, c2="" a3=c, b3="", c3=""

the blank cells in range can vary.

how can copy (using vba) non-blank values myrange , paste them let's column aa?

eg: aa1=a aa2=b aa3=c aa4=d aa5=e aa6=f

thanks again guys :-) paul

iterate through cells in myrange, if cell not "" copy value next target cell

sub test()     dim myrange range     dim targetcell range     dim rw range     dime cl range      set myrange = activeworkbook.names("myrange").referstorange     set targetcell = range("aa1")      each rw in myrange.columns         each cl in rw.cells             if cl.value <> ""                 targetcell = cl.value                 set targetcell = targetcell.offset(1,0)             end if         next     next  end sub 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -