Multiple List Clear

kod2th3e

Board Regular
Joined
Apr 2, 2008
Messages
87
I have a list on sheet3 that is generated by a user and a list on sheet2 that is automatically provided. What I would like to have happen is when when a macro is run on sheet3 it goes down the list (could be variable in length) item by item and clears any identical values in sheet2. For example:

Sheet2:
Col1
123a
123b
123c
123d
123e
123f

Sheet3:
Col1
123a
123c
123f

So, when the macro is run it'll find 123a, 123c, & 123f on sheet2 and clear them but nothing else.

Thanks in advance for looking/providing assistance,
-Cody
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
1) On Sheet2, if there is not a row of titles in row1, insert one
2) Put this formula in B1 and copy down:

=ISNUMBER(MATCH(A1, Sheet3!A:A, 0))

3) You now have a list TRUE/FALSE for all the matches.

4) Turn on the Data > Filter > Autofilter

5) Filter column B for "TRUE"

6) Delete all visible rows

7) Turn off the autofilter and clear column B.
 
Upvote 0
I was hoping to accomplish this with a looping macro. I have headings at the top of each column, I was just looking for something to go to the first item on sheet3 find and delete it on sheet2 then go to the next item on sheet3 and find and delete it on sheet2 and so on. Thoughts?

Thanks for the response,
Cody
 
Upvote 0
The technique shown is the correct method to use, even if you turn on the macro recorder and let it record you doing all that. Then a few small tweaks will give you a reausable macro.

Never loop line by line when you can evaluate the entire data range all at once, delete all at once.

Try it... turn on the macro recorder, then follow the steps above manually. When done, paste your resulting code here and we can tweak that into something reusable.
 
Upvote 0
I changed the formula a little bit to match my needs a little better:

=IFERROR(IF(MATCH(B3,'Sheet 3'!$A:$A,0),"Y","N"),"N")

The isnumber wasn't working all the time because of the varying length in the values (wasn't always a number or not always text). I appreciate the help it has greatly reduced some frustration.

Thanks,
-Cody
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top