Link to home
Start Free TrialLog in
Avatar of lkirke
lkirkeFlag for Australia

asked on

Macro to merge cells across columns based upon criteria

Hello experts,

I would like to have a macro that merges three columns based upon a set of criteria.

For instance, I have four columns of data, and for all rows with data in column A, if column D has data, but where also column B and C are blank, then merge column A with column B and column C.

Please find attached an example as a illustration.

Could anyone provide some assistance?

Regards

LK
EE-Example-Merge-Columns.xlsm
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try
Sub macro()
For Each c In Range(Range("A2"), Range("A" & Cells.Rows.Count).End(xlUp))
    If c.Offset(0, 3) <> "" Then
        c.Resize(1, 3).Merge
    End If
Next
End Sub

Open in new window

Regards
Avatar of lkirke

ASKER

Hi Rgonzo,

Works great apart from the warning message for each merge. Is there a way to turn these off?
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lkirke

ASKER

Fantastic. Thank you.