Excel中利用VBA设置列宽和行高
时间:2023-09-01 18:20:20
如果要用VBA来设置区域的行高和列宽,可以用Range.ColumnWidth 属性和Range.RowHeight 属性,例如下例将选定的区域中各单元格的列宽和行高调整为指定的数值:
Sub SetColumnAndRow()
With ActiveWindow.RangeSelection
.ColumnWidth = 3
.RowHeight = 19
End With
End Sub
如果要将选定区域内的各单元格的列宽和行高调整为最合适的值,可以用下面的代码:
Sub SetColumnAndRow()
With ActiveWindow.RangeSelection
.Columns.AutoFit
.Rows.AutoFit
End With
End Sub
下面的代码将活动工作表中的所有单元格的行高和列宽恢复为默认值:
Sub SetDefault()
With ActiveSheet
.Columns.ColumnWidth = .StandardWidth
.Rows.RowHeight = .StandardHeight
End With
End Sub
标签:单元格,可以用,属性,选定,Excel函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Win10麦克风自动调节音量怎么关闭?
2022-06-12 05:34:30
![](https://img.aspxhome.com/file/2023/1/a272260_0s.jpg)
win10系统如何还原成win7?win10系统还原win7怎么操作?
2022-11-26 06:33:36
![](https://img.aspxhome.com/file/2023/30/a271557_0s.jpg)
WPS excel如何用YEAR函数快速提取年份
2023-10-16 22:37:54
![](https://img.aspxhome.com/file/2023/6/a184886_0s.png)
Word文件中怎么插入本地视频?
2023-03-29 01:36:43
![](https://img.aspxhome.com/file/2023/4/30754_0s.jpg)
文件误删不要怕,帮你找回Win10回收站清空文件
2023-12-27 00:36:28
![](https://img.aspxhome.com/file/2023/26/a224236_0s.jpg)
Win10如何卸载已安装补丁?Win10卸载已安装补丁的方法
2023-11-16 08:21:39
![](https://img.aspxhome.com/file/2023/4/52314_0s.jpg)
win10系统调出平板模式以体验平板效果
2023-12-01 11:58:08
![](https://img.aspxhome.com/file/2023/28/a250897_0s.png)
开机自动宽带连接联网方法总结 五种方法供您选择
2022-06-06 18:14:00
![](https://img.aspxhome.com/file/2023/29/a257715_0s.jpg)
win7安装不了itunes怎么办?win7安装不了itunes的解决办法
2023-08-08 11:16:27
![](https://img.aspxhome.com/file/2023/30/a263731_0s.jpg)
PPT如何绘制“波浪”时间线?
2023-06-22 02:42:19
![](https://img.aspxhome.com/file/2023/10/a352814_0s.gif)
Win11电脑切换窗口卡顿怎么解决
2022-08-21 01:07:16
![](https://img.aspxhome.com/file/2023/1/a275409_0s.jpg)
windows 10 build 9926 到底更新了什么?更新内容汇总(最新)
2023-03-11 18:15:19
![](https://img.aspxhome.com/file/2023/29/a252122_0s.png)
Win7电脑屏幕翻转了不会恢复怎么办?Win7电脑屏幕翻转恢复教程
2022-03-10 17:03:37
![](https://img.aspxhome.com/file/2023/26/a228314_0s.png)
word 模板文件的扩展名是什么
2022-09-04 23:33:38
![](https://img.aspxhome.com/file/2023/7/33247_0s.jpg)
逗拍怎么充值金币?逗拍充值金币的方法
2023-06-20 20:42:27
![](https://img.aspxhome.com/file/2023/7/a332711_0s.jpg)
PDF怎么删除其中一页
2022-05-06 15:22:37
![](https://img.aspxhome.com/file/2023/9/a342618_0s.jpg)
excel筛选怎么筛选不出来?excel筛选不了数据解决教程
2023-08-31 07:40:47
![](https://img.aspxhome.com/file/2023/30/a267721_0s.jpg)
wps ppt怎么添加超链接
2023-07-25 04:12:15
excel记分里怎么排序的方法
2022-06-15 23:45:46
新版Win10菜单变了:教你开启Win10彩色菜单
2023-10-30 03:42:24
![](https://img.aspxhome.com/file/2023/4/a310901_0s.jpg)