Created
April 1, 2022 13:10
-
-
Save wavezhang/c633097a8a14385a63c83ecfa8b3f65f to your computer and use it in GitHub Desktop.
Excel 合并相同单元格
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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