Results 1 to 28 of 28

Merge cells in corresponding column based on similar values

Threaded View

Niclal Merge cells in corresponding... 11-19-2014, 01:56 PM
PCI Re: Merge cells in... 11-19-2014, 02:04 PM
PCI Re: Merge cells in... 11-19-2014, 02:44 PM
Niclal Re: Merge cells in... 11-19-2014, 05:47 PM
PCI Re: Merge cells in... 11-20-2014, 02:25 AM
Niclal Re: Merge cells in... 11-20-2014, 03:33 AM
PCI Re: Merge cells in... 11-20-2014, 05:05 AM
PCI Re: Merge cells in... 11-20-2014, 05:11 AM
Niclal Re: Merge cells in... 11-21-2014, 10:55 AM
PCI Re: Merge cells in... 11-22-2014, 05:28 AM
Niclal Re: Merge cells in... 11-24-2014, 01:53 PM
PCI Re: Merge cells in... 11-24-2014, 03:38 PM
Niclal Re: Merge cells in... 11-25-2014, 06:17 AM
PCI Re: Merge cells in... 11-25-2014, 03:25 PM
Niclal Re: Merge cells in... 11-26-2014, 11:20 AM
PCI Re: Merge cells in... 11-26-2014, 01:09 PM
Niclal Re: Merge cells in... 11-26-2014, 02:23 PM
PCI Re: Merge cells in... 11-26-2014, 03:09 PM
Niclal Re: Merge cells in... 11-28-2014, 03:24 AM
PCI Re: Merge cells in... 11-28-2014, 04:52 AM
Niclal Re: Merge cells in... 12-01-2014, 03:46 AM
PCI Re: Merge cells in... 12-01-2014, 02:40 PM
Niclal Re: Merge cells in... 12-09-2014, 03:38 AM
PCI Re: Merge cells in... 12-09-2014, 03:42 PM
Niclal Re: Merge cells in... 12-10-2014, 04:27 AM
PCI Re: Merge cells in... 12-10-2014, 05:05 PM
Niclal Re: Merge cells in... 12-22-2014, 09:34 AM
PCI Re: Merge cells in... 12-22-2014, 10:54 AM
  1. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Merge cells in corresponding column based on similar values

    Try

    Option Explicit
    
    Sub MergeData()
    Dim ObjDic   As Object
    Dim WkRg   As Range
    Dim F  As Range
    Dim Temp
    Dim J  As Integer
        Set ObjDic = CreateObject("Scripting.Dictionary")
        Set WkRg = Sheets("Before").Cells(3, 1).CurrentRegion
        Set WkRg = Intersect(WkRg, WkRg.Offset(1, 0))
        
        With ObjDic
            For Each F In WkRg.Columns(1).Cells
                If (.exists(F.Value)) Then
                    Temp = .Item(F.Value)
                    For J = 1 To UBound(Temp, 2)
                        If (Not (IsEmpty(F.Offset(0, J)))) Then
                            If (Len(Temp(1, J)) = 0) Then
                                Temp(1, J) = F.Offset(0, J)
                            Else
                                Temp(1, J) = Temp(1, J) & ", " & F.Offset(0, J)
                            End If
                        End If
                    Next J
                    .Item(F.Value) = Temp
                Else
                    .Item(F.Value) = F.Offset(0, 1).Resize(1, 4).Value
                End If
            Next F
            Sheets("After").Cells(3, 1).CurrentRegion.Offset(1, 0).Cells.ClearContents
            Sheets("After").Range("A4").Resize(.Count, 1) = Application.Transpose(.keys)
            Sheets("After").Range("B4").Resize(.Count, 4) = Application.Transpose(Application.Transpose(.items))
        End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to Merge Cells based on Other Column Values
    By meystingray in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-19-2014, 11:10 AM
  2. Merge values from column in one cell, based on duplicates in another column
    By Rawland_Hustle in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-24-2014, 11:04 AM
  3. Running Macro with Do Loop of similar based on values in a Column
    By fishycarl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 03:50 AM
  4. How to transpose a column based on similar values
    By tdunford7 in forum Excel General
    Replies: 4
    Last Post: 02-28-2012, 12:51 AM
  5. [SOLVED] Copying cells with similar column values
    By mohd21uk via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-15-2006, 04:35 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