如何设置列宽与行高,如何转换mm单位 您所在的位置:网站首页 excel表格列宽磅怎么设置厘米 如何设置列宽与行高,如何转换mm单位

如何设置列宽与行高,如何转换mm单位

2024-07-12 06:27| 来源: 网络整理| 查看: 265

Sub 设置厘米行高()

    Dim cm As Single

    cm = Application.InputBox("请输入以厘米为单位的行高数值", _

        "设置行高(cm)", Type:=1)

    If cm Then

        Selection.RowHeight = Application.CentimetersToPoints(cm)

    End If

End Sub

 

Sub 设置厘米列宽()

 

    Dim cm As Single, points As Integer, savewidth As Integer

    Dim lowerwidth As Integer, upwidth As Integer, curwidth As Integer

    Dim Count As Integer

 

    Application.ScreenUpdating = False

    cm = Application.InputBox("请输入以厘米为单位的列宽数值", _

        "设置列宽(cm)", Type:=1)

    If cm = False Then Exit Sub

    points = Application.CentimetersToPoints(cm)

    savewidth = ActiveCell.ColumnWidth

    ActiveCell.ColumnWidth = 255

    If points > ActiveCell.Width Then

        MsgBox "列宽" & cm & " 设置得过宽." & Chr(10) & _

            "最大值为" & _

            Format(ActiveCell.Width / 28.3464566929134, _

            "0.00"), vbOKOnly + vbExclamation, "错误的列宽"

        ActiveCell.ColumnWidth = savewidth

        Exit Sub

    End If

    lowerwidth = 0

    upwidth = 255

    ActiveCell.ColumnWidth = 127.5

    curwidth = ActiveCell.ColumnWidth

    Count = 0

    While (ActiveCell.Width points) And (Count < 20)

        If ActiveCell.Width < points Then

            lowerwidth = curwidth

            Selection.ColumnWidth = (curwidth + upwidth) / 2

        Else

            upwidth = curwidth

            Selection.ColumnWidth = (curwidth + lowerwidth) / 2

        End If

        curwidth = ActiveCell.ColumnWidth

        Count = Count + 1

    Wend

End Sub



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有