vba - Copy paste Excel data in -
i have 2 sheets, sheet1 , sheet2. sheet1 data have copy data , paste in sheet2, again sheet1 have copy different set of data , paste in sheet2 last line, pasted data 1st time
sub copy_chains_to_other_sheet() activesheet.range("$a$1").autofilter field:=8, criteria1:="<>1", _ operator:=xland activesheet.range("$a$1:$i$681").autofilter field:=1, criteria1:="=*antaris*" _ , operator:=xland range("a1").select range(selection, selection.end(xldown)).select range(selection, selection.end(xltoright)).select selection.copy activesheet.next.select activesheet.paste activesheet.range("$a$1").autofilter field:=1
end sub
this macro wrote, don't know how proceed. because 1 time have 5 rows of data time need copy data sheet1 , paste in sheet2 , next set of data need paste in 6th row, time have 8 row of data time need paste next set of data 9the row onwards, how deal this.
thanks in advance answering.
regards, vignesh
if understand correctly want copy results of successive autofiltered data sheet1 continuous "list" in sheet2. if perhaps try following going. need alter variables/names suit requirement, have made assumptions.
option explicit sub copyafs() dim wsone worksheet, wstwo worksheet dim onestrow long, oneendrow long, onestcol long, oneendcol long dim twostrow long, twonextrow long, twostcol long dim crit1col long, crit2col long dim crit1 string, crit2 string set wsone = sheets("sheet1") set wstwo = sheets("sheet2") onestrow = 1 onestcol = 1 oneendcol = 10 twostrow = 1 twostcol = 1 crit1 = "antaris" crit2 = "1" crit1col = 1 crit2col = 8 wstwo twonextrow = .cells(.rows.count, twostcol).end(xlup).row + 1 end 'clear autofilter wsone.autofiltermode = false 'apply autofilter wsone oneendrow = cells(rows.count, onestcol).end(xlup).row + 1 .range(.cells(onestrow, onestcol), .cells(oneendrow, oneendcol)) 'set autofilter .autofilter field:=crit1col, criteria1:=crit1 .autofilter field:=crit2col, criteria1:=crit2 end end 'copy filtered range without header wstwo wsone.autofilter.range.offset(1, 0).copy destination:=.range(.cells(twonextrow, twostcol), .cells(twonextrow, twostcol)) end 'clear autofilter wsone.autofiltermode = false end sub
Comments
Post a Comment