Vba assistance for duplicate data

Donai

Well-known Member
Joined
Mar 28, 2009
Messages
543
Hi i am new and need some assistance in removing duplicate data, i have data which gets downloaded from in house system, the data is read as text, i need a vba code which will remove duplicate entries in each row, so below is a sample


Excel Workbook
ABCDE
100014789901478990147899
200673123067312306731230673120673123
Manual_Securities_Aliases v


I need the code to do this

Excel Workbook
AB
10001478990147899
2006731230673123
Manual_Securities_Aliases v
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
try
Code:
Sub test()
Dim a() As String, i As Long, ii As Long
Set dic = CreateObject("Scripting.Dictionary")
With Range("a1").CurrentRegion
    ReDim a(1 To .Rows.Count, 1 To Columns.Count)
    For i = 1 To .Rows.Count
        For ii = 1 To .Columns.Count
            If (.Cells(i, ii).Value <> "") * (Not dic.exists(.Cells(i, ii).Text))Then
                n = n + 1 : dic(.Cells(i, ii).Text) = Empty 
                a(i, n) = .Cells(i, ii).Text
            End If
        Next
        dic.removeall
    Next
    .Value = a
End With
End Sub
 
Last edited by a moderator:
Upvote 0
Hello Seiya, i did test and i got an error 424 Object required

If (.Cells(i, ii) <> "") * (Not dic.exists(r.Text)) Then

try
Code:
Sub test()
Dim a() As String, i As Long, ii As Long
Set dic = CreateObject("Scripting.Dictionary")
With Range("a1").CurrentRegion
    ReDim a(1 To .Rows.Count, 1 To Columns.Count)
    For i = 1 To .Rows.Count
        For ii = 1 To .Columns.Count
            If (.Cells(i, ii) <> "") * (Not dic.exists(r.Text)) Then
                n = n + 1 : dic(r.Text) = Empty 
                a(i, n) = .Cells(i, ii).Text
            End If
        Next
        dic.removeall
    Next
    .Value = a
End With
End Sub
 
Upvote 0
try this one
Code:
Sub test()
Dim a() As String, i As Long, ii As Long
Set dic = CreateObject("Scripting.Dictionary")
With Range("a1").CurrentRegion
    ReDim a(1 To .Rows.Count, 1 To Columns.Count)
    For i = 1 To .Rows.Count
        For ii = 1 To .Columns.Count
            If (.Cells(i, ii).Value <> "") * (Not dic.exists(.Cells(i, ii).Text))Then
                n = n + 1 : dic(.Cells(i, ii).Text) = Empty 
                a(i, n) = .Cells(i, ii).Text
            End If
        Next
        dic.removeall : n = 0
    Next
    .Value = a
End With
End Sub
 
Last edited by a moderator:
Upvote 0
Great, this works as required, thankyou very much Seiya.

try this one
Code:
Sub test()
Dim a() As String, i As Long, ii As Long
Set dic = CreateObject("Scripting.Dictionary")
With Range("a1").CurrentRegion
    ReDim a(1 To .Rows.Count, 1 To Columns.Count)
    For i = 1 To .Rows.Count
        For ii = 1 To .Columns.Count
            If (.Cells(i, ii).Value <> "") * (Not dic.exists(.Cells(i, ii).Text))Then
                n = n + 1 : dic(.Cells(i, ii).Text) = Empty 
                a(i, n) = .Cells(i, ii).Text
            End If
        Next
        dic.removeall : n = 0
    Next
    .Value = a
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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