• 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.

Pull Values if any duplicate find then pull all values

Abhijeet

Active Member
Hi

I tried to do this in Formula based i use this formula please tell me in VBA how to do this

=IFERROR(INDEX('Main Data'!$B$3:$B$17,SMALL(IF('Main Data'!$A$3:$A$17='Expecetd result'!$A1,ROW('Main Data'!$B$3:$B$17)-ROW('Main Data'!$B$3)+1),COLUMNS($B1:B1))),"")
 

Attachments

  • Multipal values pull.xlsx
    11.3 KB · Views: 5
For the data provided.
Code:
Sub test()
    Dim a, i As Long, w
    a = Sheets("main data").[a3].CurrentRegion.Value
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 1 To UBound(a, 1)
            If Not .exists(a(i, 1)) Then
                .Item(a(i, 1)) = Array(.Count + 1, 1)
                a(.Count, 1) = a(i, 1)
            End If
            w = .Item(a(i, 1))
            w(1) = w(1) + 1: .Item(a(i, 1)) = w
            If UBound(a, 2) < w(1) Then ReDim Preserve a(1 To UBound(a, 1), 1 To w(1))
            a(w(0), w(1)) = a(i, 2)
        Next
        Sheets("Expecetd result").Cells(1).Resize(.Count, UBound(a, 2)).Value = a
    End With
End Sub
 
Back
Top