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 :)
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top