remove duplicates from multiple columns

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
840
Office Version
  1. 2013
Platform
  1. Windows
I have some duplicate data which I need to highlight so I can delete. What complicates this is that to determine what's a duplicate I need to look at multiple columns.

The data is in columns A and B, and I want to remove the duplicate data from col B. So normally I'd just set a conditional format on col B and then delete the duplicates. But in this case col B is just dollar values, so a lot of valid data would show up as a duplicate. I only want to delete data in col B IF the corresponding cell in col A is also a duplicate.

How would I do that?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I only want to delete data in col B IF the corresponding cell in col A is also a duplicate.

Here's a quick example of how you could accomplish this:

Code:
Sub dupremove()    
     For Each cell In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
        If InStr(0, cell.Value, cell.Offset(0, 1).Value) = 0 Then
            'values are not duplicate, do nothing
        Else
            'code to remove the duplicate, such as:
            cell.Offset(0, 1).Value = ""
        End If
    Next cell
End Sub
 
Last edited:
Upvote 0
thanks a lot!

unfortunately i cant use VBA at work. I should've mentioned that, sorry.

Is there another way?


Here's a quick example of how you could accomplish this:

Code:
Sub dupremove()    
     For Each cell In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
        If InStr(0, cell.Value, cell.Offset(0, 1).Value) = 0 Then
            'values are not duplicate, do nothing
        Else
            'code to remove the duplicate, such as:
            cell.Offset(0, 1).Value = ""
        End If
    Next cell
End Sub
 
Upvote 0
thanks a lot!

unfortunately i cant use VBA at work. I should've mentioned that, sorry.

Is there another way?

No, without VBA, you can only write formulas or use conditions to indicate which cells should be deleted. Formulas cannot change another cell's value based on a condition.
 
Upvote 0
The only alternative workaround is to write your own addin that you load into your work instance of excel. But that really depends on your work/group policies. They may block that as well.
 
Upvote 0

Forum statistics

Threads
1,214,849
Messages
6,121,922
Members
449,056
Latest member
denissimo

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