billandrew
Well-known Member
- Joined
- Mar 9, 2014
- Messages
- 743
Evening all
Attempting to modify the code below which combines/joins Column A & Column B into Column C on Sheet1 then removes the duplicate value and places them on Sheet 2.
Looking to join Column A & Column B and remove duplicates and place in Sheet1, Starting at [C1]
This is the current code
This is my bad attempt to perform the aforementioned request/assistance.
Any help as always will be appreciated. Trying to get this Scripting Dictionary, a bit difficult at times.
THANK YOU!
Attempting to modify the code below which combines/joins Column A & Column B into Column C on Sheet1 then removes the duplicate value and places them on Sheet 2.
Looking to join Column A & Column B and remove duplicates and place in Sheet1, Starting at [C1]
This is the current code
Code:
Sub Unique2Colum() Dim ary As Variant
Dim d As Object
Dim c As Variant
Dim lastrow As Long
Dim i As Long, j As Long
Dim sh As Worksheet, sh2 As Worksheet
Set sh = Worksheets("Sheet1")
Set sh2 = Worksheets("Sheet2")
ary = sh.Range("A2", Range("A" & Rows.Count).End(xlUp).Offset(, 2)).Value
For i = 1 To UBound(ary)
ary(i, 3) = ary(i, 1) & " " & ary(i, 2)
Next i
sh.Range("C1").Resize(UBound(ary)).Value = Application.Index(ary, 0, 3)
Set d = CreateObject("Scripting.Dictionary")
lastrow = sh.Cells(Rows.Count, 3).End(xlUp).Row
c = Range("c1:c" & lastrow)
For j = 1 To UBound(c, 1)
d(c(j, 1)) = 1
Next j
sh2.Range("A1").Resize(d.Count) = Application.Transpose(d.Keys)
End Sub
This is my bad attempt to perform the aforementioned request/assistance.
Code:
Sub GetUniques2Columns()Dim c As Range
Dim v As String
With CreateObject("Scripting.dictionary")
For Each c In Range("A2", Range("A" & Rows.Count).End(xlUp))
v = Join(Application.Index(c.Resize(, 2).Value, 1, 0), "|")
If Not .exists(v) Then
.Add v, Nothing
End If
Next c
For Each c In Range("A2", Range("A" & Rows.Count).End(xlUp))
v = Join(Application.Index(c.Resize(, 2).Value, 1, 0), "|")
'If .exits(v) Then c.offset(, col) [COLOR=#ff0000]I believe this is where i'm going off path, all of above may be off as well[/COLOR]
Next c
End With
End Sub
Any help as always will be appreciated. Trying to get this Scripting Dictionary, a bit difficult at times.
THANK YOU!