+ Reply to Thread
Results 1 to 7 of 7

Need VBA Macro to Consolidate data

Hybrid View

jbaillie Need VBA Macro to Consolidate... 02-07-2023, 09:19 PM
jbaillie Re: Need VBA Macro to... 02-07-2023, 09:20 PM
beyond Excel Re: Need VBA Macro to... 02-07-2023, 11:46 PM
jbaillie Re: Need VBA Macro to... 02-08-2023, 12:51 PM
bebo021999 Re: Need VBA Macro to... 02-08-2023, 02:41 AM
jbaillie Re: Need VBA Macro to... 02-08-2023, 12:36 PM
bebo021999 Re: Need VBA Macro to... 02-08-2023, 09:39 PM
  1. #1
    Registered User
    Join Date
    02-11-2016
    Location
    Lincoln, CA
    MS-Off Ver
    2010
    Posts
    8

    Post Need VBA Macro to Consolidate data

    I have attached a spreadsheet with example of data I am trying to consolidate. This spreadsheet will be used to request records from provider offices.

    In Colum B and C contain Clients name. But you can see in Column at they may have more than one value being requested from provider office in column F thru N.

    The original sheet contains over 5,000 lines.

    I need a Macro that will consolidate the data in column "A" if the client is listed more than once and request is going to the same provider office.

    I have highlighted on the sheet where the duplicates are at . I need to have the sheet consolidate that data.

    Any help you could give would be greatly appreciated. This macro will save me 1 to 2 days of work.

    Thank you,
    Judy
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    02-11-2016
    Location
    Lincoln, CA
    MS-Off Ver
    2010
    Posts
    8

    Re: Need VBA Macro to Consolidate data

    Typo: But you can see in Column "A" they may have more than one value being requested from provider office in column F thru N

  3. #3
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Need VBA Macro to Consolidate data

    .
    Hi jbaillie.

    Upload your workbook to the Forum again but -this time- you must include a second sheet in which you will show us what the expected final result is.
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  4. #4
    Registered User
    Join Date
    02-11-2016
    Location
    Lincoln, CA
    MS-Off Ver
    2010
    Posts
    8

    Re: Need VBA Macro to Consolidate data

    I have attached spread sheet on how the data should look after the Macro runs.

    Thank you,
    Judy

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,678

    Re: Need VBA Macro to Consolidate data

    Try this:
    PHP Code: 
    Option Explicit
    Sub consolidate
    ()
    Dim lr&, i&, j&, k&, rngid As Stringarr(1 To 100001 To 14)
    Dim dic As Objectkey
    Set dic 
    CreateObject("Scripting.Dictionary")
    With Sheets("Sheet1")
        
    lr = .Cells(Rows.Count"D").End(xlUp).Row
        rng 
    = .Range("A2:N" lr).Value
        
    For 1 To UBound(rng)
            
    id rng(i4) & "|" rng(i6) & "|" rng(i7)
            If 
    Not dic.exists(idThen
                dic
    .Add idrng(i1)
                
    1
                
    For 1 To 14
                    arr
    (kj) = rng(ij)
                
    Next
            
    Else
                
    dic(id) = dic(id) & ";" rng(i1)
                For 
    1 To k
                    
    If arr(j4) & "|" arr(j6) & "|" arr(j7) = id Then arr(j1) = dic(id)
                
    Next
            End 
    If
        
    Next
        
    .Range("A2:N10000").ClearContents
        
    .Range("A2").Resize(dic.Count14).Value arr
    End With
    End Sub 
    Attached Files Attached Files
    Quang PT

  6. #6
    Registered User
    Join Date
    02-11-2016
    Location
    Lincoln, CA
    MS-Off Ver
    2010
    Posts
    8

    Re: Need VBA Macro to Consolidate data

    I get Run-time error '9':
    Subscript out of range

    It shows the error highlighted in yellow in attachment. How do I fix?
    Thank you,
    Attached Files Attached Files

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,678

    Re: Need VBA Macro to Consolidate data

    Make sure you have sheet name "Sheet1"
    This is the working file.
    Attached Files Attached Files

+ 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. [SOLVED] Macro to Consolidate Data
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-26-2022, 11:33 AM
  2. [SOLVED] macro to consolidate data
    By nr6281 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-28-2018, 07:23 PM
  3. Macro to consolidate data from sheet into another?
    By koska in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-27-2018, 11:01 PM
  4. Macro to consolidate data into new or existing tab
    By jw01 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-20-2018, 11:43 AM
  5. Macro to consolidate data from many files
    By Masa1989 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-15-2015, 07:56 AM
  6. [SOLVED] Need Macro to Consolidate data
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-12-2015, 07:08 AM
  7. Macro to consolidate data from various worksheets into one
    By Archana in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-31-2007, 08:10 AM

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