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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
63,296
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,802
Messages
5,833,755
Members
430,230
Latest member
Doug G

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
Top