VBA Remove only certain duplicates

floggingmolly

Board Regular
Joined
Sep 14, 2019
Messages
167
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet with data in columns A thru F. In column A are contract #'s and in F are percentages. If there are duplicates contract #'s in A, and in column F one of the duplicate contracts is at 100% I need to delete the one that is not 100%. If neither is 100% I need to keep both. Is this possible with VBA?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I vaguely understand...but, could you provide a few examples?
 
Upvote 0
Thought I had a macro, but didn't.
 
Last edited:
Upvote 0
I vaguely understand...but, could you provide a few examples?

I can send you an example. I don't think it's possible because the ones that are 100% turn green. The 100% isn't actually shown on the sheet. It feeds from data on another sheet. So basically I have duplicates where neither row is green meaning neither is at 100%. Then I have duplicates where 1 might be green since it's 100% and one is not green because it's below 100%. I need to delete the duplicates where one is green and the other is not. Wouldn't be a big deal except there's over 2000 entries on the sheet.
 
Upvote 0
Does this accomplish it?

Code:
Sub molly()
Dim LR As Long, i As Integer
LR = Cells(Rows.Count, "A").End(xlUp).Row
 For i = LR To 1 Step -1
  If (Cells(i, 6) = 1) And (WorksheetFunction.CountIf(Range("A1:A" & LR), Range("A" & i)) > 1) Then
    Rows(i).EntireRow.Delete
  Else
  End If
 Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

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