excel - VBA Check duplicates (column) and copy cells from one row to another that is duplicate -
excel 2007 [vb] in macro filter color find duplicated values (on column "j" have highlight cells rules - duplicates). duplicated records in column "j" named in column "k" "copy" or "original".i find "copy" each "original" record under (but not 1 more rows) , copy cells value column n:r of "copy" row row "original".
i hope wrote if not screenshot under.
table
begining of macro:
sub copy_original() dim lastrow long dim wb2 excel.workbook application.displayalerts = false application.alertbeforeoverwriting = false application.screenupdating = true set wb2 = thisworkbook wb2.sheets("sheet1").autofiltermode = false wb2.sheets("sheet1").range("a4:u4").autofilter field:=10, criteria1:=rgb(255, 204, 0), operator:=xlfiltercellcolor lastrow = wb2.sheets("sheet1").cells(rows.count, "c").end(xlup).row x = lastrow 5 step -1 if... ... wb2.sheets("sheet1").autofiltermode = false end sub
i looked similiar can , found such scripts:
check if 1 cell contains exact same data cell vba
find cells same value within 1 column , return values separate column of same row
excel: check if cell value exists in column, , return value in same row different column
but honest can't figure out how connect 1 working macro. gratefull help.
try this:
sub copy_original() dim filteredrng range, cl range, rw integer
application.displayalerts = false application.alertbeforeoverwriting = false application.screenupdating = true thisworkbook.worksheets("sheet1") .autofiltermode = false .range("a4:u4").autofilter field:=10, criteria1:=vbred, operator:=xlfiltercellcolor set filteredrng = .range("j5:j" & .cells(rows.count, "j").end(xlup).row) each cl in filteredrng.specialcells(xlcelltypevisible) if cl.offset(0, 1) = "original" range("l" & rw & ":r" & rw).copy destination:=cl.offset(0, 2) end if rw = cl.row next cl .autofiltermode = false end
end sub
Comments
Post a Comment