excel - I want to paste the rows for the items in Sheet1 Table 1 that are not in Sheet2 Table 2 into Sheet3 with vba -
so have list of products in table 1, column 1 in sheet1, have updated list in table 2, column 1 in sheet2. want able see new products have been added , paste respective rows sheet 2 blank sheet 3. (so paste whatever isn't in sheet1 in sheet 2 new sheet.
i tried using vlookup application function within code it's not working out well. when run macro, nothing happens. appreciated!
sub try() dim last1 long dim colpartnum integer thisworkbook.sheets("newv") last1 = .cells(.rows.count, "a").end(xlup).row colpartnum = .range("table2[part number]").column p = last1 1 step -1 on error resume next if .cells(p, colpartnum) = application.worksheetfunction.vlookup("table2[part number]", "table1[part number]", 1, false).value _ .cells(p, "a").entirerow.copy worksheets("addedparts").range("a1").endxldown.offset(1, 0).paste next p end end sub
range
doesn't include paste
method. use pastespecial
instead or, better yet, copy , paste in 1 statement using optional destination
parameter of method.
Comments
Post a Comment