+ Reply to Thread
Results 1 to 4 of 4

Using Macros to combine multiple lines of data when Address column data is the same.

  1. #1
    Registered User
    Join Date
    09-22-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    2

    Using Macros to combine multiple lines of data when Address column data is the same.

    Hi everyone,

    I'm new at this and not sure exactly how this works but I need help with a Macro. As shown in the attached sample file, I have a worksheet with names and addresses. What I am attempting to do is combine all the names where the address is the same. For example, if I have a Jason Ambros who lives at 10 Dyson Dr, Parkdale and later down the worksheet there is a David Johnson who lives at the same address, I would like the rows to be merged so the names column now shows "Jason, David".

    I hope this makes sense and someone can help me!
    Attached Files Attached Files

  2. #2
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129

    Re: Using Macros to combine multiple lines of data when Address column data is the same.

    Try this code, but I wonder how about "given name" and "other given name"?
    PHP Code: 
    Sub ExtractData()
    Dim SArr(), RArr()
    Dim EndR As LongAs LongAs LongRCount As Long
    Dim Dic 
    As ObjectTestStr As String
    Set Dic 
    CreateObject("Scripting.Dictionary")
    EndR Sheet1.[a65000].End(xlUp).Row
    SArr 
    Sheet1.Range("A1:J" EndR)
    ReDim RArr(1 To EndR1 To 10)
    For 
    1 To EndR
        TestStr 
    SArr(i4) & SArr(i5) & SArr(i6) & SArr(i7) & SArr(i8)
        If 
    Not Dic.exists(TestStrThen
            RCount 
    RCount 1
            Dic
    .Add TestStrRCount
            
    For 1 To 10
                RArr
    (RCountj) = SArr(ij)
            
    Next
        
    Else
            
    RArr(Dic.Item(TestStr), 1) = RArr(Dic.Item(TestStr), 1) & ", " SArr(i1)
        
    End If
    Next
    Sheet2
    .Cells.ClearContents
    Sheet2
    .[a1].Resize(RCount10) = RArr
    End Sub 
    Sampleworksheet.xlsm
    Last edited by ptm0412; 09-22-2012 at 11:22 PM.
    Oldman Chatting: [email protected] Mailing: [email protected]

  3. #3
    Registered User
    Join Date
    09-22-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    2

    Re: Using Macros to combine multiple lines of data when Address column data is the same.

    Hi,

    I tried this macro but it says Runtime error 429, ActiveX component can't create object

  4. #4
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129

    Re: Using Macros to combine multiple lines of data when Address column data is the same.

    Chrispy,
    On the menu Tools of VBA window (open by Alt + F11), choose References. Then pull down the scroll bar, find and check the item "Microsoft Scripting runtime"

    Anyway, see my attached file in my previous post above
    Last edited by ptm0412; 09-23-2012 at 01:28 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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