BENatUSGS
06-17-2011, 12:02 PM
Hey All,
Have a quick question on how to remove duplicates through VB :dunno
If you look at the attached spread sheet(Hopefully I attached it correctly)..Sheet1 has multiple duplicates.
Excel has a nice remove duplicate feature that give the following code…
Columns("A:B").Select
ActiveSheet.Range("$A$1:$B$100000").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlYes
Sheet2 is the output of sheet1 after the code has finished.
As you can see National Canyon has been removed which is what I want. However, you can see that Paria was not removed because the Site # is different in column B. What I need the code to do is recognize that Paria is a duplicate in column A and then check if the site number is different in column B. If so, I would like to give the user an error stating the duplicates and highlight those rows. Any help would be much appreciated.
Thanks,
Ben
Have a quick question on how to remove duplicates through VB :dunno
If you look at the attached spread sheet(Hopefully I attached it correctly)..Sheet1 has multiple duplicates.
Excel has a nice remove duplicate feature that give the following code…
Columns("A:B").Select
ActiveSheet.Range("$A$1:$B$100000").RemoveDuplicates Columns:=Array(1, 2), Header _
:=xlYes
Sheet2 is the output of sheet1 after the code has finished.
As you can see National Canyon has been removed which is what I want. However, you can see that Paria was not removed because the Site # is different in column B. What I need the code to do is recognize that Paria is a duplicate in column A and then check if the site number is different in column B. If so, I would like to give the user an error stating the duplicates and highlight those rows. Any help would be much appreciated.
Thanks,
Ben