• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Unique Data Pull with Duplicate names

Abhijeet

Active Member
Hi

I have data i show how to display expected result please tell me i tried some part VBA in pull unique values
Code:
Sub A_Unique_B()
Dim X
Dim objDict As Object
Dim lngRow As Long

Set objDict = CreateObject("Scripting.Dictionary")
X = Application.Transpose(Range([B1], Cells(Rows.Count, "B").End(xlUp)))

For lngRow = 1 To UBound(X, 1)
    objDict(X(lngRow)) = 1
Next
Range("E1:E" & objDict.Count) = Application.Transpose(objDict.keys)
End Sub
 

Attachments

  • Duplicate Doc ref.xlsx
    13.1 KB · Views: 8
In your pivot table, can you move "Name" field to column? Currently "Name" field is in row. Will this help? If you still need names in each row it can be handled via code.
 
Hi !

Just with Excel basics …​
Code:
Sub Macro1()
     Const DR = 15
     Application.ScreenUpdating = False
     Cells(DR, 8).CurrentRegion.Clear
With Cells(1).CurrentRegion.Columns
    F$ = "SUMPRODUCT((" & .Item(1).Address & "=""#A"")*(" & .Item(2).Address & "=""#B""))"
    VA = .Item("A:B").Value
End With
For R& = 2 To UBound(VA)
    If VA(R, 1) & VA(R, 2) <> N$ & S$ Then
             N = VA(R, 1)
             S = VA(R, 2)
        With Cells(DR, 8).CurrentRegion
                V = Application.Match(S, .Columns(1), 0)
            If IsError(V) Then
                L& = L& + 1
                .Cells(L, 1).Resize(, 3).Value = Array(S, Evaluate(Replace(Replace(F, "#A", N), "#B", S)), N)
            Else
                    W = Application.Match(N, .Rows(V), 0)
                If IsError(W) Then
                    With .Cells(V, 2)
                         .Value = .Value + Evaluate(Replace(Replace(F, "#A", N), "#B", S))
                         .End(xlToRight)(1, 2).Value = N
                    End With
                End If
            End If
        End With
    End If
Next
    Application.ScreenUpdating = True
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
Back
Top