Hi All!! I'm new to this forum, I searched through other threads and didn't see an answer to my question, but if i overlooked i'm sorry, and if you could point me in the right direction it would be great!
My question is: Is there a way to remove duplicates, but prioritized by data on a different column? Example:
Acct # Yes/No
1234 1
1234 1
1212 0
1212 0
5444 0
5444 1
6767 1
6767 0
8787 0
8787 0
9191 1
9191 1
I need it to sort out all the duplicates. If in the 2nd column of the duplicates has a "1" and a "0" in it, to leave the row that has the "1" in it and remove the one that has the "0". Or if they both have a "0" then leave one that has a "0", or if they both have a "1" then leave one that has a "1".
So example of the results from the previous raw data:
Acct # Yes/No
1234 1
1212 0
5444 1
6767 1
8787 0
9191 1
as you can see both the 5444 and 6767 had both "0"'s and "1"'s and it only left the "1"'s.
Bottom line the "1"s take priority over the "0"s but if they both have "0"s then it needs to remain "0".
I hope my question isn't confusing.
I know a little about using VBA to program a macro, so if this can be done with a formula or a marco it will be very helpful to me.
Thanks for your help in advance.
Last edited by rmikulas; 07-08-2010 at 08:21 AM.
Here's a little macro to do it:
Option Explicit Sub DeleteDupes() Dim DelRNG As Range Dim LR As Long Dim Rw As Long LR = Range("A" & Rows.Count).End(xlUp).Row Set DelRNG = Range("A" & LR + 10) Columns("A:B").Sort Key1:=Range("A2"), Order1:=xlAscending, _ Key2:=Range("B2"), Order2:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal, DataOption2:=xlSortNormal For Rw = 3 To LR If Cells(Rw, "A") = Cells(Rw - 1, "A") Then _ Set DelRNG = Union(Cells(Rw, "A"), DelRNG) Next Rw DelRNG.EntireRow.Delete xlShiftUp Set DelRNG = Nothing End Sub
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Thank you SOOOOO much.... I had really been having trouble trying to figure this one out!!! You just saved me HOURS of work everyday!! Thank you thank you!!!![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks