|
- Sub 合并单元格()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim i&, j&, s&
- i = Sheets("取消合并单元格").Cells(Rows.Count, 3).End(3).Row
- For j = i To 5 Step -1
- If Cells(j, 2) = Cells(j - 1, 2) Then
- Range(Cells(j, 2), Cells(j - 1, 2)).Merge
- End If
- Next
- Range("B5:B" & i).Copy
- Range("A5:A" & i).PasteSpecial Paste:=xlPasteFormats
- Application.CutCopyMode = False
- i = Sheets("取消合并单元格").Cells(Rows.Count, 8).End(3).Row
- For j = i To 5 Step -1
- If Cells(j, 7) = Cells(j - 1, 7) Then
- Range(Cells(j, 7), Cells(j - 1, 7)).Merge
- End If
- Next
- Range("g5:g" & i).Copy
- Range("f5:f" & i).PasteSpecial Paste:=xlPasteFormats
- Application.CutCopyMode = False
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
- Sub 取消合并()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim i&, j&, m&, StrMer, s&
- i = Sheets("取消合并单元格").Cells(Rows.Count, 3).End(3).Row
- With Sheets("取消合并单元格")
- For m = 1 To 2
- For j = 5 To i
- StrMer = .Cells(j, m).Value
- s = .Cells(j, m).MergeArea.Count
- .Cells(j, m).UnMerge
- .Range(.Cells(j, m), .Cells(j + s - 1, m)).Value = StrMer
- j = j + s - 1
- Next
- Next
- End With
- i = Sheets("取消合并单元格").Cells(Rows.Count, 8).End(3).Row
- With Sheets("取消合并单元格")
- For m = 6 To 7
- For j = 5 To i
- StrMer = .Cells(j, m).Value
- s = .Cells(j, m).MergeArea.Count
- .Cells(j, m).UnMerge
- .Range(.Cells(j, m), .Cells(j + s - 1, m)).Value = StrMer
- j = j + s - 1
- Next
- Next
- End With
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|