vba - .FIND function with .FIND and Offset() -
i writing code in excel 3 sheets, sheet 1 display data not appear in sheet2 sheet3, in order acomplish code following;
dim r excel.range dim cell excel.range set r = sheet3.range(sheet3.cells(1, 1), sheet3.cells(rows.count, 1).end(xlup)) dim currowsheet1 long currowsheet1 = 1 each cell in r set rfind = sheet2.range("a:a").find(cell.value) if (rfind nothing) cell.entirerow.copy sheet1.cells(currowsheet1, 1) currowsheet1 = currowsheet1 + 1 end if next cell note: trying include second .find under line 9 "set rfind" if looks cell values in column ("a:Ä") , verifies values same column ("b:b") both sheets 2 , 3, thinking can use offset() function compare data, advise on appreciated!!!!
thanks.
instead of range.find, recommend using worksheetfunction.countifs
sub tgr() dim acell range each acell in sheet3.range("a1", sheet3.cells(rows.count, "a").end(xlup)).cells if worksheetfunction.countifs(sheet2.columns("a"), acell.value, sheet2.columns("b"), acell.offset(, 1).value) = 0 acell.entirerow.copy sheet1.cells(rows.count, "a").end(xlup).offset(1) end if next acell end sub
Comments
Post a Comment