excel - Copy data from a worksheet to another stepping by 6 -
i have bit of problem : have 3 worksheets:
- a.xlsm, - b.xlsm - c.xlsm.
the worksheets have 1 sheet (sheet1) .the 3 worksheets fixed , not change. want copy cells
a.xlsm- f1, l1, s1, w1 (jumping 6 cells) b.xlsm-column h- h1, h2, h3, h4 , a.xlsm- f2, l2, s2, w2 copy in c.xlsm- column h- h1, h2, h3, h4.
any welcomed. thank you.
sub testcopydata() dim wba workbook dim wbb workbook set wba = activeworkbook set wbb = "\\hofs\mike1.xlsm" dim sheeta worksheet dim sheetb worksheet sheeta = wba.sheets("sheet1") sheetb = wbb.sheets("sheet1") dim rowa integer dim lastrowa integer lastrowa = sheeta.cells(sheeta.rows.count, 1).end(xlup).row dim cola integer dim lastcola integer lastcola = sheeta.cells(1, sheeta.columns.count).end(xltoleft).column
if strcomp(sheets("sheeta").cells(aa, 1).value, sheets("sheetb").cells(a, 1).value) = 0
then
for rowa = 1 lastrowa cola = 1 lastcola sheetb.cells(cola, "w").value = sheeta.cells(row, (cola * 6)).value next cola next row else: exit sub
end sub
i made test code below in witch put dates of year 1 one if filter found copy cell worksheet need doesn't work good.
sub fetchdata3() sheets("sheet3").select sheets("sheet2").range("a1:i50000").advancedfilter action:= _ xlfiltercopy, criteriarange:=range("j1:j2"), copytorange:=range("a1:i1"), _ unique:=false
end sub
i had time, made code can use start, you'll have add more data:
sub testcopydata() dim wba workbook dim wbb workbook dim wbc workbook set wba = "a.xlsm" 'you'll need open or define each workbook set wbb = "b.xlsm" set wbc = "c.xlsm" dim sheeta worksheet dim sheetb worksheet dim sheetc worksheet sheeta = wba.sheets("sheet1") sheetb = wbb.sheets("sheet1") sheetc = wbc.sheets("sheet1") dim rowa integer dim lastrowa integer lastrowa = sheeta.cells(sheeta.rows.count, 1).end(xlup).row dim cola integer dim lastcola integer lastcola = sheeta.cells(1, sheeta.columns.count).end(xltoleft).column rowa = 1 lastrowa cola = 1 lastcola sheetb.cells(cola, "h").value = sheeta.cells(row, (cola * 6)).value next cola next row end sub
this not tested , it's exception writes code here, know....
Comments
Post a Comment