+ Reply to Thread
Results 1 to 23 of 23

Search and list multiple names

Hybrid View

  1. #1
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Search and list multiple names

    Hi,

    See if this code can help you. It's using a Dictionary of Dictionaries.
    It's not complete because it only compiles the February data but it should get you started. What it does is take the data for February and outputs it to a new sheet called Output.

    By adding a loop you could go through each month in the "Data entry" sheet and compile the results.

    Sub test()
        Dim ar
        Dim i As Long, j As Long
        Dim DicC, DicP, e, s
        Dim sMonth As String
        Dim m As Integer, n As Long
    
        Set DicC = CreateObject("Scripting.dictionary")
    
        ar = Sheets("Data Entry").Range("A1").Cells(1).CurrentRegion.Value
        sMonth = ar(1, 1)
    
        For i = 3 To UBound(ar, 1)
            If Not DicC.exists(ar(i, 1)) Then
    
                Set DicC.Item(ar(i, 1)) = CreateObject("Scripting.dictionary")
    
                For j = 4 To UBound(ar, 2) Step 2
                    If ar(i, j) <> "" Then
    
                        With DicC(ar(i, 1))
                            If Not DicC(ar(i, 1)).exists(ar(i, j)) Then
                                DicC.Item(ar(i, 1))(ar(i, j)) = ar(i, j - 1)
                            Else
                                DicC.Item(ar(i, 1))(ar(i, j)) = DicC.Item(ar(i, 1))(ar(i, j)) + ar(i, j - 1)
                            End If
                        End With
    
                    End If
    
                Next j
            End If
        Next i
    
        m = 1
        With Sheets("Output")
            .Range("A1") = sMonth
            For Each e In DicC
                If DicC(e).Count > 0 Then
                    .Cells(2, m) = e
                    .Cells(2, m + 1) = "Amount"
                    n = 3
                    For Each s In DicC(e)
                        .Cells(n, m) = s
                        .Cells(n, m + 1) = DicC(e)(s)
                        n = n + 1
                    Next s
                    m = m + 2
                End If
            Next e
        End With
    
    End Sub
    Attached Files Attached Files
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Search a range Last Names for age & return the value to a List of FULL NAMES
    By LunarLights in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-16-2014, 05:02 PM
  2. [SOLVED] Search a list of names and automatically return any names not already included in table
    By bishbash89 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-21-2013, 09:06 AM
  3. Search Multiple Worksheets Against List of Non-Exact Search Criteria?
    By thump4r in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2010, 03:46 PM
  4. Search and Copy files from a list of file names excel vba programming
    By aashishnawal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2010, 09:27 AM
  5. how do I search a word or pdf for a list of names in a CSV file?
    By Martin Crane in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2008, 05:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1