Results 1 to 18 of 18

Macro Needed to Concatenate Data in separate ROWS

Threaded View

  1. #13
    Registered User
    Join Date
    02-06-2015
    Location
    Italy
    MS-Off Ver
    Office 2007 & 2013
    Posts
    78

    Re: Macro Needed to Concatenate Data in separate ROWS

    Quote Originally Posted by jindon View Post
    My code are both working on your file.

    It may raise the error for the bulky data, so I said post back if you get the error.

    Or maybe we are talking about different EXCEL.


    Option Explicit
    
    Sub test()
        Dim a, i As Long
        With Range("a1", Range("a" & Rows.Count).End(xlUp)).Resize(, 2)
            a = .Value
            With CreateObject("Scripting.Dictionary")
                .CompareMode = 1
                For i = 1 To UBound(a, 1)
                    If a(i, 1) <> "" Then
                        If Not .exists(a(i, 1)) Then
                            .Item(a(i, 1)) = .Count + 1
                            a(.Item(a(i, 1)), 1) = a(i, 1)
                            a(.Item(a(i, 1)), 2) = a(i, 2)
                        Else
                            a(.Item(a(i, 1)), 2) = _
                            Join(Array(a(.Item(a(i, 1)), 2), a(i, 2)), "-")
                        End If
                    End If
                Next
                i = .Count
            End With
            .Offset(, .Columns.Count + 2).Resize(i, 2).Value = a
            Application.Goto .Offset(, .Columns.Count + 2).Cells(1), True
        End With
    End Sub
    
    
    Sub testToOtherSheet()
        Dim a, i As Long
        With Sheets("1")
            a = .Range("a1", .Range("a" & Rows.Count).End(xlUp)).Resize(, 2).Value
        End With
        With CreateObject("Scripting.Dictionary")
            .CompareMode = 1
            For i = 1 To UBound(a, 1)
                If a(i, 1) <> "" Then
                    If Not .exists(a(i, 1)) Then
                        .Item(a(i, 1)) = .Count + 1
                        a(.Item(a(i, 1)), 1) = a(i, 1)
                        a(.Item(a(i, 1)), 2) = a(i, 2)
                    Else
                        a(.Item(a(i, 1)), 2) = _
                        Join(Array(a(.Item(a(i, 1)), 2), a(i, 2)), "-")
                    End If
                End If
            Next
            i = .Count
        End With
        With Sheets("2").Cells(1).Resize(i, 2)
            .CurrentRegion.ClearContents
            .Value = a
        End With
    End Sub

    Hello,

    Your code works on the test file;
    But If I try the macro on the original file (larger) It doesn't appears nothing on second sheet.






    thanks



    thanks
    Last edited by 823; 02-22-2015 at 09:03 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro Needed to Concatenate Data in separate COLUMNS
    By 823 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-11-2015, 04:34 PM
  2. [SOLVED] Macro Needed to Concatenate Data in separate ROWS
    By 823 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-21-2015, 11:35 AM
  3. [SOLVED] Macro needed to Concatenate data in 2 separate tables of 2 separate sheets
    By 823 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 02-08-2015, 02:02 PM
  4. [SOLVED] Macro needed to Concatenate Data in separate TABLES
    By 823 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-08-2015, 07:42 AM
  5. [SOLVED] VBA/Macro help needed for splitting wrapped cell values into separate (bottom) rows
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2013, 01:30 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