Skip to content

Instantly share code, notes, and snippets.

@wavezhang
Created April 1, 2022 13:10
Show Gist options
  • Save wavezhang/c633097a8a14385a63c83ecfa8b3f65f to your computer and use it in GitHub Desktop.
Save wavezhang/c633097a8a14385a63c83ecfa8b3f65f to your computer and use it in GitHub Desktop.
Excel 合并相同单元格
Sub 合并相同的单元格()
Dim ln%, a%, b%
Application.DisplayAlerts = False
ln = [A65536].End(xlUp).Row
For b = 1 To 5 Step 1
For a = ln To 2 Step -1
If Cells(a, b) = Cells(a - 1, b) Then
Range(Cells(a - 1, b), Cells(a, b)).Merge
End If
Next
Next
Application.DisplayAlerts = True
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment