Hi again
I tried to get the unique value of each column in the range "RD" and displays them in single column so I need to create an object ("scripting.Dictionary") are just as much the number of columns in Range "RD". I tried this code but result in "Run time error 91"
loop_to.xlsm![]()
Private Sub CommandButton1_Click() Range(Me.RefEdit1).Name = "RD" Range(Me.RefEdit2).Name = "OT" Dim d As Object, c As Variant, i As Long, s As Long Dim JK As Long Dim o As Collection JK = Range("RD").Columns.Count d = CreateObject("Scripting.Dictionary") For k = 0 To JK + 1 c = Range("RD").Columns(k + 1) Set o = New Collection o.Name = "Name is " & k d.Add k, o For i = 1 To UBound(c, 1) o(c(i, 1)) = 1 Next i Range("OT").Cells((k * 5) + 2, 2).Resize(d.Count) = Application.Transpose(d.Keys) Range("OT").Cells((k * 5) + 2, 2).Resize(d.Count).Sort Key1:=Range("OT").Cells((k * 5) + 2, 2).Resize(d.Count) Next k End Sub
any help will be appreciated
Bookmarks