|
楼主 |
发表于 2022-6-16 14:34
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
以下这个程序,只能单行,请大神帮我修改一下,万分感谢,改成可以多行同时调整的
Sub 批量增减行高()
Dim h, rng As Range, cel As Range, Area As Range, nh As Single, RngAdr$, tmp, i&
h = InputBox("请输入行高增量值", "批量增加选定区域的行高")
h = Val(h)
If h = 0 Then Exit Sub
RngAdr = "," & ActiveWindow.RangeSelection.EntireRow.Address
tmp = Split(RngAdr, ",")
Set rng = Range(tmp(1))
For i = 2 To UBound(tmp)
Set rng = Union(rng, Range(tmp(i)))
Next
Set rng = rng.Rows
Application.ScreenUpdating = False
For Each Area In rng.Areas
For Each cel In Area.Columns(1)
nh = cel.RowHeight + h
If nh < 0 Then nh = 0
cel.RowHeight = nh
Next
Next
End Sub |
|