Sub 调整合并单元格行高() Dim cel As Range Dim rng As Range Dim n, r, c Dim mergeWidth, newHeight, celWidth
Set rng = Range("B4") ForEach cel In rng If cel.MergeCells Then With cel.MergeArea mergeWidth = 0 ForEach c In .Columns '合并区域中的每一个单元格 mergeWidth = mergeWidth + c.ColumnWidth '新合并区域列宽=每一列列宽宽的和 Next
n = .Rows.Count ForEach r In .Rows r.RowHeight = newHeight / n * 1.1'调整每一行的行高,并*1.1微调 Next .HorizontalAlignment = xlCenter '左右居中 .VerticalAlignment = xlCenter ''上下居中 EndWith EndIf Next EndSub
n = .Columns.Count ForEach c In .Columns c.ColumnWidth = newWidth / n * 1.1'调整每一列的列宽,并*1.1微调 Next .HorizontalAlignment = xlCenter '左右居中 .VerticalAlignment = xlCenter '上下居中 EndWith EndIf Next EndSub