Remove Duplicates from Multiple Sheets Using VBA

linister

New Member
Joined
Jan 16, 2021
Messages
23
Office Version
  1. 2019
Platform
  1. Windows
Hi Guys,

What's the VBA to remove the duplicate value from Column 1, across multiple sheets? Knowing that I only want the duplicate value in column 1 to be removed, not the data in the column 2 next to it.


Thanks in advance!
Lin
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
What About
VBA Code:
Public Sub RmvDBL()

Dim Sht As Worksheet
Dim Rng As Range
Dim TxT As String
    For Each Sht In ThisWorkbook.Worksheets
    TxT = ""
        With Sht
        LstRw = .Cells(Rows.Count, 1).End(xlUp).Row
            For Each Rng In Sht.Cells(1, 1).Resize(LstRw, 1)
                T = Rng.Value
                If InStr(1, TxT, "|" & T, vbTextCompare) <> 0 Then
                 Rng.ClearContents
                Else
                End If
                TxT = TxT & "|" & T
            Next
        End With
    Next
End Sub
 
Upvote 0
What About
VBA Code:
Public Sub RmvDBL()

Dim Sht As Worksheet
Dim Rng As Range
Dim TxT As String
    For Each Sht In ThisWorkbook.Worksheets
    TxT = ""
        With Sht
        LstRw = .Cells(Rows.Count, 1).End(xlUp).Row
            For Each Rng In Sht.Cells(1, 1).Resize(LstRw, 1)
                T = Rng.Value
                If InStr(1, TxT, "|" & T, vbTextCompare) <> 0 Then
                 Rng.ClearContents
                Else
                End If
                TxT = TxT & "|" & T
            Next
        End With
    Next
End Sub
Thank you!!
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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