Removing Duplicates - Same Row

ReggaeYT

New Member
Joined
Jul 24, 2014
Messages
16
hey all -

I may be overthinking this one, but I'm having difficulty removing duplicate codes on the same row. Transposing is not an option - Excel keeps rejecting it, as I have 1729 rows with between 1 and 16 codes in them. Unfortunately, some are duplicates and I'd like to get rid of them in a single stroke, but I'm not sure how. Duplicates are also not necessarily next to each other, so a for loop macro won't work for me (and my limited VBA experience).

Below is a small example of what I'm working with.

[TABLE="width: 647"]
<colgroup><col><col span="4"><col><col span="6"></colgroup><tbody>[TR]
[TD]28oz Daily Granite Spray[/TD]
[TD]1501[/TD]
[TD]1501[/TD]
[TD]1501[/TD]
[TD]1501[/TD]
[TD]1522[/TD]
[TD]1553[/TD]
[TD]1501[/TD]
[TD]1501[/TD]
[TD]1502[/TD]
[TD]1555[/TD]
[TD]1501[/TD]
[/TR]
[TR]
[TD]28oz Granite Spray OrangeTngr[/TD]
[TD]1501[/TD]
[TD]1553[/TD]
[TD]1501[/TD]
[TD]1502[/TD]
[TD]1555[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]68oz Granite Refill[/TD]
[TD]1501[/TD]
[TD]1522[/TD]
[TD]1553[/TD]
[TD]1555[/TD]
[TD]1501[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]68ozGranite OrangeTngrRefill[/TD]
[TD]1501[/TD]
[TD]1553[/TD]
[TD]1555[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks for any help!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How about
Code:
Sub ReggaeYT()
    Dim Cl As Range, c As Range
    
    With CreateObject("scripting.dictionary")
        For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
            For Each c In Cl.Offset(, 1).Resize(, 16)
                .Item(c.Value) = Empty
            Next c
            Cl.Offset(, 1).Resize(, 16).ClearContents
            Cl.Offset(, 1).Resize(, .Count).Value = .Keys
            .RemoveAll
        Next Cl
    End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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