Excel 有一个内置的“合并”功能,允许您突出显示一个范围,然后自动合并每行中的所有单元格,但不合并行本身(主要用于报告)。你能对列做同样的事情吗?
Excel 本身不支持“合并”。我为函数写了一个宏:
Sub MergeDown()
Dim i As Integer, NumCols As Integer, NumRows As Integer, _
LocX As Integer, LocY As Integer
LocX = Selection.Column
LocY = Selection.Row
NumCols = Selection.Columns.Count
NumRows = Selection.Rows.Count
For i = 1 To NumCols
Range(Cells(LocY, LocX + i - 1), Cells(LocY + NumRows - 1, _
LocX + i - 1)).Select
On Error GoTo ErrorHandler
Selection.Merge
Next
Exit Sub
ErrorHandler: Exit Sub
End Sub
Run Code Online (Sandbox Code Playgroud)
PS:您真的不应该合并单元格,因为它会使工作表变得非常困难。
| 归档时间: |
|
| 查看次数: |
14165 次 |
| 最近记录: |