tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
This code will remove duplicates from column A, so if my data was:
it will return:
Here is the code:
But how can I adapt it so that if my data contains 2 columns, that it looks for duplicates in column A and then returns BOTH columns of data, eg
and I want it to return:
Thanks
Code:
a
a
b
c
d
it will return:
Code:
a
b
c
d
Here is the code:
Code:
Dim DIC As Object
Set DIC = CreateObject("Scripting.Dictionary")
Dim MyArray() As Variant
MyArray() = Sheet1.Cells(1, 1).CurrentRegion.Value
Dim n As Long
For n = 1 To UBound(MyArray(), 1)
DIC.Item(MyArray(n, 1)) = 0
Next n
MyArray() = DIC.Keys
Dim NewArray() As Variant
ReDim NewArray(1 To DIC.Count - 1) As Variant
Dim a As Long
For a = 1 To DIC.Count - 1
NewArray(a) = MyArray(a)
Next a
But how can I adapt it so that if my data contains 2 columns, that it looks for duplicates in column A and then returns BOTH columns of data, eg
Code:
a 1
a 2
b 3
c 4
d 5
and I want it to return:
Code:
a 1
b 3
c 4
d 5
Thanks
Last edited: