excel中能不能输入一个函数,按表格中给定的数据自动调整行高喃?
发布网友
发布时间:2022-04-26 04:42
我来回答
共4个回答
热心网友
时间:2023-10-06 04:23
能
Sub 按数据调整行高()
Dim x, y
x = Selection.Row() '行坐标
y = Selection.Column() '列坐标
Dim a As Long
a = Cells(x, y).Rows.CurrentRegion.Count
For i = 0 To a
Cells(i + 1, y).Select
Selection.RowHeight = Cells(i + 1, y).Value
Next
End Sub
选择b1执行此宏
热心网友
时间:2023-10-06 04:24
函数是不能调整行高的,可以用vba来获取单元格数值,并根据这些数值设定对应行的行高
热心网友
时间:2023-10-06 04:24
Sub RngToPoints()
With Range("B1")
.RowHeight = Application.CentimetersToPoints(2)
End With
With Range("B2")
.RowHeight = Application.InchesToPoints(3)
End With
End Sub
如果你行高是数组,那就直接引用过来
热心网友
时间:2023-10-06 04:25
需要VBA编程:代码类似于
Sub Macro1()
Dim i As Integer
For i = 1 To 5
Rows(i).RowHeight = Cells(i, "B").Value
Next
End Sub
不知是否有帮助