excel - Remove entire row based on match? -
need remove multiple rows within csv file in excel based on match in column l on sheet1 column on sheet2. content email addresses. how can achieve this?
so, if sheet2 column has email address matches of email addresses in sheet1 - column l, should remove entire row sheet1 email address located.
sheet1 below: 
sheet2 below: 
@mehow, here's image when run code module: 
this work, fast looking doesn't involve loops.
sub deleteduplicates() dim startingscreenupdatevalue boolean dim startingeventsvalue boolean dim startingcalculations xlcalculation application startingscreenupdatevalue = .screenupdating startingeventsvalue = .enableevents startingcalculations = .calculation .screenupdating = false .enableevents = false .calculation = xlcalculationmanual end dim vartestvalues variant dim sh1 worksheet dim sh2 worksheet set sh1 = sheets("sheet1") set sh2 = sheets("sheet2") sh2 vartestvalues = .range("a1", .range("a" & .rows.count).end(xlup)) end sh1.range("l1", sh1.range("l" & sh1.rows.count).end(xlup)) _ .autofilter field:=12, criteria1:=application.transpose(vartestvalues), operator:=xlfiltervalues sh1.range("l2", sh1.range("l" & sh1.rows.count).end(xlup)) _ .specialcells(xlcelltypevisible).entirerow.delete sh1.autofiltermode = false application .screenupdating = startingscreenupdatevalue .enableevents = startingeventsvalue .calculation = startingcalculations end end sub note: code runs assuming data has headers if not please advise.
remember run code on copy of data , not actual data until confident working 100%.
Comments
Post a Comment