跳至主要内容

如何在 Excel 中将单元格大小设置为厘米 (cm)?

Author: Xiaoyang Last Modified: 2025-05-07

在工作表中,行高和列宽的默认单位是预设的,默认列宽为 8.38 个字符,默认行高为 12.75 磅。在 Excel 中,很难直接以英寸或厘米为单位设置行高或列宽。但有时出于某些目的,您需要将高度和宽度更改为厘米。该如何解决这个问题呢?

使用 VBA 代码将单元格大小设置为厘米 (cm)

使用 Kutools for Excel 将单元格大小设置为厘米 (cm) good idea


arrow blue right bubble 使用 VBA 代码将单元格大小设置为厘米 (cm)

除了使用 VBA 代码外,您无法通过 Excel 的功能以厘米为单位设置高度和宽度。以下两个代码可以帮助您设置列宽和行高。操作步骤如下:

1. 选择要以厘米为单位设置的单元格。

2. 单击 开发工具 > Visual Basic,会弹出一个新的 Microsoft Visual Basic for Applications 窗口,单击 插入 > 模块,并将以下代码输入到模块中:

用于设置行高(以厘米为单位)的代码:

Sub RowHeightInCentimeters()
Dim cm As Single
cm = Application.InputBox("Enter Row Height in Centimeters", _
"Row Height (cm)", Type:=1)
If cm Then
Selection.RowHeight = Application.CentimetersToPoints(cm)
End If
End Sub

3. 然后点击Run button 按钮执行代码。此时会弹出一个提示框,要求您输入行高的数值。参见截图:

Dialog for entering row height

备注:您输入的数字必须小于 15。如果您在此对话框中输入 0,此 VBA 代码不会更改行高。

4. 单击 确定。所选单元格的行高已设置为 2 厘米。参见截图:

Cells of original row height Arrow Cells of adjusted row height

如果要以厘米为单位设置列宽,可以输入以下代码:

用于设置列宽(以厘米为单位)的代码:

Sub ColumnWidthInCentimeters()
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("Enter Column Width in Centimeters", _
"Column Width (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 "Width of " & cm & " is too large." & Chr(10) & _
"The maximum value is " & _
Format(ActiveCell.Width / 28.3464566929134, _
"0.00"), vbOKOnly + vbExclamation, "Width Error"
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

arrow blue right bubble 使用 Kutools for Excel 将单元格大小设置为厘米 (cm)

通过上述代码,您只能以厘米为单位设置单元格大小。今天,我将向您介绍一款多功能工具——Kutools for Excel,它不仅可以以厘米为单位设置单元格大小,还可以以英寸、磅和像素为单位进行设置。

Kutools for Excel 提供了超过 300 种高级功能,简化复杂任务,提升创造力与效率。 通过集成 AI 能力,Kutools 能够精准自动执行任务,让数据管理变得轻松简单。Kutools for Excel 的详细信息...         免费试用...

安装 Kutools for Excel 后,请按照以下步骤操作:(立即免费下载 Kutools for Excel!)

1. 选中要以厘米为单位设置的单元格。

2. 单击 Kutools > 格式 > 调整单元格大小,参见截图:

Adjust Cell Size option on the Kutools tab on the ribbon

3. 在“调整单元格大小”对话框中,选择所需的 单位类型,并从 设置数值 部分指定 行高列宽。参见截图:

Adjust Cell Size dialog box

4. 然后单击 确定应用。您将获得行高为 2 厘米、列宽为 3 厘米的单元格。

Cell size ajusted


arrow blue right bubble 演示:使用 Kutools for Excel 将单元格大小设置为厘米 (cm)

Kutools for Excel:超过 300 种实用工具触手可及!永久免费享受 AI 功能!立即下载!

相关文章:

为某个区域设置列宽和行高

如何在 Excel 中将多个单元格设置为正方形?

最佳办公效率工具

🤖 Kutools AI 助手:基于智能执行生成代码创建自定义公式分析数据并生成图表调用 Kutools 函数等功能,彻底改变数据分析方式…
热门功能查找、高亮或标记重复项 | 删除空行 | 合并不丢失数据的列或单元格 | 四舍五入 ...
高级 LOOKUP多条件 VLookup | 多值 VLookup | 多表查找 | 模糊查找 ....
高级下拉列表快速创建下拉列表 | 从属下拉列表 | 多选下拉列表 ....
列管理器添加指定数量的列 | 移动列 | 切换隐藏列的可见状态 | 比较区域和列 ...
精选功能网格聚焦 | 设计视图 | 增强编辑栏 | 工作簿与工作表管理器 | 资源库(自动文本) | 日期提取 | 合并数据 | 加密/解密单元格 | 按列表发送电子邮件 | 超级筛选 | 特殊筛选(筛选粗体/斜体/删除线...)...
排名前 15 的工具集12 种文本 工具添加文本删除特定字符等) | 50 多 种图表 类型甘特图等) | 40 多种实用 公式基于生日计算年龄等) | 19 种插入 工具插入二维码根据路径插入图片等) | 12 种转换 工具小写金额转大写汇率转换等) | 7 种合并与分割 工具高级合并行分割单元格等) | 还有更多...

使用 Kutools for Excel 提升您的 Excel 技能,体验前所未有的高效。 Kutools for Excel 提供超过 300 种高级功能来提高生产力并节省时间。 单击此处获取您最需要的功能...


Office Tab 将标签式界面引入 Office,让您的工作更加轻松

  • 在 Word、Excel、PowerPoint 中启用标签式编辑和阅读
  • 在同一窗口的新标签页中打开和创建多个文档,而不是在新窗口中进行操作。
  • 将您的生产力提升 50%,每天为您减少数百次鼠标点击!