ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   scan for repeating values and then delete (https://www.excelbanter.com/excel-programming/271226-scan-repeating-values-then-delete.html)

peach255 C

scan for repeating values and then delete
 
I would like to loop through Column B, and if I find the same repeating
value, then I would like to delete the rows and keep only one. I would
always have 4 replicates, but would only like to keep one. For ex., Loop
through Column B, and if found "A2" multiple times, then delete 3 out of
the 4 rows. The values would vary. I do not want to sort Column B first
though.

I have the following so far, and don't know how to check to see if the
values are repeating.

For lRow = Range(Cells(1, 2), Cells(Cells.Rows.Count,
2).End(xlUp)).Rows.Count To 1 Step -1
......
Next

Thank you!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Chong Moua

scan for repeating values and then delete
 
You don't have to use loops. Just use the advance filter
and check unique records only. See below...
------------------------------------
Sub FilterUnique()

Range("B:B").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("C1"), Unique:=True

End Sub
------------------------------------
Hope this helps...

Chong Moua

-----Original Message-----
I would like to loop through Column B, and if I find the

same repeating
value, then I would like to delete the rows and keep only

one. I would
always have 4 replicates, but would only like to keep

one. For ex., Loop
through Column B, and if found "A2" multiple times, then

delete 3 out of
the 4 rows. The values would vary. I do not want to sort

Column B first
though.

I have the following so far, and don't know how to check

to see if the
values are repeating.

For lRow = Range(Cells(1, 2), Cells(Cells.Rows.Count,
2).End(xlUp)).Rows.Count To 1 Step -1
......
Next

Thank you!



*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.



All times are GMT +1. The time now is 07:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com