trouble merging cells based on common data

detroit54

New Member
Joined
Nov 28, 2005
Messages
2
Hi,

I have a worksheet with two columns of data. Column A contains filenames with dates (i.e. "Activities for 091305"). Column B contains a list of activities (all text). I start by sorting the entire worksheet by Column A so the dates are in ascending order. Then I manually go through and cut and paste all the values from Col B that have common file names. Example:

Col A Col B
Activities for 091305.xls List of activities part 1
Activities for 091305.xls List of activities part 2

The result I'm looking for is:

9/12/2005 List of activities part 1; List of activities part 2

Naturally this is very time consuming and I'm trying to find a better way to accomplish this repetitive task. I had some trouble converting the text date in Col A from ddmmyy to d/m/yyyy format, so I'll settle for being able to combine the cells in Col B and just manually enter the date if necessary.

I have tried the concatenate command using IF statements, but there could be any number of rows that have common filenames so it looks like a loop would be better suited for this task.

Any help is appreciated :)
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,430
Office Version
  1. 365
Platform
  1. Windows
Welcome to the board!

Use a simple macro to perform that task.

If you sort all of your data by column A, then this macro will concatenate all values of column B together where the values in column A are the same, and delete the extra rows:
Code:
Sub CombineCells()

    Dim i As Long
    For i = Range("A65536").End(xlUp).Row To 2 Step -1
        If Cells(i, "A") = Cells(i - 1, "A") Then
            Cells(i - 1, "B") = Cells(i - 1, "B") & "; " & Cells(i, "B")
            Rows(i).EntireRow.Delete
        End If
    Next i
    
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,521
Messages
5,572,627
Members
412,475
Latest member
JaredNAU
Top