Excel VBA Match First & Last Names from sheet 1 to sheet 2 and delete all matches on sheet 1 -


some 1 awesome.

in "sheet 3" have database of "last name" in column "b" & "first name" in column "c". same list of names in "sheet 2", "last name" in column e & "first name" in column "f"

i need delete matches sheet 2 @ click of button. need able change how many rows down "sheet 2" matches stop, example @ first 600 rows on "sheet 2".

i hope explained enough.

this code have been using clear specific ranges horrible , may need change ranges, makes method impractical.

sub clearselection()      sheets("adult sign on sheet").select     range("e6:f36").select     selection.clearcontents     range("e42:f72").select     selection.clearcontents     range("e78:f108").select     selection.clearcontents     range("e114:f144").select     selection.clearcontents     range("e150:f180").select     selection.clearcontents     range("e186:f216").select     selection.clearcontents     range("e222:f252").select     selection.clearcontents     range("e258:f288").select     selection.clearcontents     range("e294:f324").select     selection.clearcontents     range("e330:f360").select     selection.clearcontents  end sub 

putting politics of site's intentions aside minute, see if can started on applying vba yourself.

sub clearselection_and_dedupe()     dim r long, v variant, ws3 worksheet      application.screenupdating = false     application.enableevents = false      sheets("adult sign on sheet")         r = 6 330 step 36             .cells(r, 5).resize(31, 2).clearcontents         next r     end      on error goto fìn     set ws3 = sheets("sheet 3")     sheets("sheet 2")         r = application.max(.cells(rows.count, 5).end(xlup).row, .cells(rows.count, 6).end(xlup).row)         v = inputbox(prompt:="how many rows at?", default:=r)         r = application.sum(v) 2 step -1             if cbool(application.countifs(ws3.columns(2), .cells(r, 5).value, ws3.columns(3), .cells(r, 6).value)) _                 .rows(r).entirerow.delete         next r     end fìn:     set ws3 = nothing     application.enableevents = true     application.screenupdating = true end sub 

that code perform you've described , i've tightened earlier cell clearing routine finding pattern areas , looping through them. tbh, loop code written as:

sheets("adult sign on sheet").range("e6:f36,e42:f72,e78:f108,e114:f144,e150:f180,e186:f216,e222:f252,e258:f288,e294:f324,e330:f360").clearcontents 

... 'for ... next` loop looks cooler.

so see if can make sense of snippets i've provided , incorporate them command button. there no end amount of instructional material available on how , site's (among others) asked q&a's excellent resource that.

if having trouble incorporating own purposes, make sure post description of problem sample showing own effort. luck!


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -