vba功能推荐

经验创意 · 36 次浏览
Harryli 创建于 8天19小时前

自由输入行高列宽的VBA代码,行高单位默认为(字符),列宽单位默认为(磅)。也就是说 列宽10 ≠ 行高10

---------------------------------------------------------------------

Sub VBA设置Excel行高列宽()

  dim intWidth as integer

  dim intHeight as integer

  intWidth = inputbox("请输入列宽")

  intHeight= inputbox("请输入行高")

  ActiveWindow.RangeSelection.ColumnWidth = intWidth

  ActiveWindow.RangeSelection.RowHeight = intHeight

End Sub

---------------------------------------------------------------------

Sub VBA设置Excel列宽()

  dim intWidth as integer

  intWidth = inputbox("请输入列宽")

  ActiveWindow.RangeSelection.ColumnWidth = intWidth

End Sub

---------------------------------------------------------------------

Sub VBA设置Excel行高()

  dim intHeight as integer

  intHeight= inputbox("请输入行高")

  ActiveWindow.RangeSelection.RowHeight = intHeight

End Sub


回复内容
Harryli 8天19小时前
#1

设置列宽为10

---------------------------------------------

 Sub width()
    Selection.ColumnWidth = 10
End Sub

---------------------------------------------

---------------------------------------------


设置行高为10

---------------------------------------------


 Sub height()
    Selection.RowHeight = 40
End Sub
回复主贴