录制一个宏,快捷键CTRL+e 把下面代码放在宏里面 Dim i, j As Integer Dim combine As String i = 0 j = 0 For Each rg In Selection If i * j = 0 Then i = rg.Row j = rg.Column End If combine = combine & rg Next rg Cells(i, j) = combine Selection.Merge
Sub ouyangff() s = "" For i = 2 To [a65536].End(3).Row If Cells(i, 1) = t Then s = s & "," & Cells(i, 2) Else n = n + 1 Sheets("处理的结果").Cells(n, 1) = t Sheets("处理的结果").Cells(n, 2) = s t = Cells(i, 1): s = Cells(i, 2) End If Next n = n + 1 Sheets("处理的结果").Cells(n, 1) = t Sheets("处理的结果").Cells(n, 2) = s Sheets("处理的结果").Select End Sub