问题
I need help finding a macro that can merge cells across rows in a specific column if those same rows are already merged in another column. Below is a screenshot of what I have now that shows the cells in Column B that need to be merged based on cells that are already merged in Column A.

The below screenshot is what I need the spreadsheet to look like after the macro runs

回答1:
nixda already answered it...
Sub mergecolumn()
Dim cnt As Integer
Dim rng As Range
Dim str As String
For i = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
cnt = Cells(i, 1).MergeArea.Count
Set rng = Range(Cells(i, 2), Cells(i - cnt + 1, 2))
For Each cl In rng
If Not IsEmpty(cl) Then str = str + vbNewLine + cl
Next
If str <> "" Then str = Right(str, Len(str) - 2)
Application.DisplayAlerts = False
rng.Merge
rng = str
Application.DisplayAlerts = True
str = ""
i = i - cnt + 1
Next i
End Sub
来源:https://stackoverflow.com/questions/17308355/macro-to-merge-cells-in-a-specific-column-if-same-rows-are-merged-in-a-different