excel - FOR NEXT or FOR EACH LOOP only works for first value -
please in making next loop following code; i'm trying copy each cell in range & past specific (fixed position) cell copy results specific (fixed position) cells , paste cells. want for each cell in range. using macro recorded code below worked perfect want make next or each loop recorded macro, please me.
'
' pastspecialcheck6 macro ' ' l1 activesheet.cells(12, 103).select selection.copy range("b9").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false range("b28:b34").select selection.copy activesheet.cells(40, 103).select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false ' l02 activesheet.cells(13, 103).select selection.copy range("b9").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false range("b28:b34").select selection.copy activesheet.cells(40, 104).select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false ' l03 activesheet.cells(14, 103).select selection.copy range("b9").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false range("b28:b34").select selection.copy activesheet.cells(40, 105).select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false
i tried code looping in vain. works 1 cell in range.
sub pastspecialmy_30july2015_2() ' ln length dim ln variant ' numbers dim integer ' l1 each ln in activesheet.range("cy12:cy30").cells = 125 143 ' ln.activate range("b9").select selection.value = ln range("b28:b34").select selection.copy activesheet.cells(57, i).select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false next next end sub
is trying?
sub sample() dim long, n long dim ws worksheet set ws = activesheet n = 103 ws = 12 30 .cells(i, 103).copy .range("b9").pastespecial paste:=xlpastevalues, _ operation:=xlnone, skipblanks:=false, transpose:=false .range("b28:b34").copy .cells(40, n).pastespecial paste:=xlpastevalues, _ operation:=xlnone, skipblanks:=false, transpose:=false n = n + 1 next end end sub
Comments
Post a Comment