可以用vba實現。程式碼如下。Sub 合併() Application.ScreenUpdating = False Application.DisplayAlerts = False On Error Resume Next m = [E65536].End(xlUp).Row x = Cells(2, 5): j = 1: z = 0 For i = 3 To m y = Cells(i, 5) If x y Then x = y If j > 1 Then Range(Cells(z, 5), Cells(z + j - 1, 5)).MergeCells = True: j = 1 Else j = j + 1 If j = 2 Then z = i - 1 End If Next i Application.DisplayAlerts = True Application.ScreenUpdating = True MsgBox "相同資料合併完成!"End Sub
可以用vba實現。程式碼如下。Sub 合併() Application.ScreenUpdating = False Application.DisplayAlerts = False On Error Resume Next m = [E65536].End(xlUp).Row x = Cells(2, 5): j = 1: z = 0 For i = 3 To m y = Cells(i, 5) If x y Then x = y If j > 1 Then Range(Cells(z, 5), Cells(z + j - 1, 5)).MergeCells = True: j = 1 Else j = j + 1 If j = 2 Then z = i - 1 End If Next i Application.DisplayAlerts = True Application.ScreenUpdating = True MsgBox "相同資料合併完成!"End Sub