excel表格怎么设置自动填充公式
时间:2023-01-21 20:19:34
excel表格中需要使公式计算,该怎么让表格自动填充输入公式呢?对于新手来说还是有一定难度,怎么办?下面就跟小编一起看看excel表格设置自动填充公式的技巧吧,欢迎大家来到学习。
excel表格设置自动填充公式的技巧
1、首先我们打开一个工作样表作为例子。
2、打开vba编辑窗口,创建一个新的模块,并输入以下代码:
Sub 填充公式()
Dim i As Long, j As Long
With Range("A1").CurrentRegion
i = .Rows.Count – 1
j = .Columns.Count – 1
End With
Range("J3").AutoFill _
Destination:=Range(Cells(3, 10), Cells(i, 10))
Range("D16").AutoFill _
Destination:=Range(Cells(16, 4), Cells(16, j))
End Sub
3、这里with是简化代码的写法,读取了当前活动单元格的区域,并将行列分别赋值为I和J变量-1。
4、简写掉的代码完整版的是Range("A1").CurrentRegion.Rows.Count和Range("A1").CurrentRegion.Columns.Count。就是这么简单和任性。
5、接着我们使用autofill函数来填充给定的单元格区域。其中,自动填充的公式单元格竖列指定的是J3,横行指定的是D13,代码如图。
6、而最终填充的区域范围,为本活动单元格的区域范围,我给的例子格式不正确,大家试试找出正确的公式和标题栏。我们创建一个宏按钮,来看一下正确运行的结果。
猜你感兴趣:
1.excel单元格公式自动填充的设定教程
2.excel表格怎么自动填充公式
3.excel不自动填充公式的设置方法
4.excel函数怎么设置自动填充上行公式
5.excel函数如何设置自动填充
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
XP 操作系统安装全程详解
![](https://img.aspxhome.com/file/2023/5/a319018_0s.jpg)
wps文字放大镜效果怎么制作图文教程
teambition使用教程_teambition怎么加入项目的教程
![](https://img.aspxhome.com/file/2023/5/a314550_0s.png)
Mac OS X笔记本如何控制访问者权限
![](https://img.aspxhome.com/file/2023/2/a216702_0s.jpg)
WPS演示插入flash的方法
![](https://img.aspxhome.com/file/2023/5/a170605_0s.jpg)
Word 2010:22个经典小技巧大放送
win7系统如何将字体还原到最初状态
![](https://img.aspxhome.com/file/2023/5/a317104_0s.jpg)
WPS表格基础教程
Win7系统磁盘压缩卷只能压缩一半容量怎么办?
![](https://img.aspxhome.com/file/2023/27/a233319_0s.jpg)
设置打开Word默认是英文输入的方法步骤
Excel中SUMSQ函数的语法和用法
![](https://img.aspxhome.com/file/2023/7/a155887_0s.png)
wps2019空心字体怎么设置?
![](https://img.aspxhome.com/file/2023/4/a182104_0s.png)
win8系统不兼容老游戏的解决方法
![](https://img.aspxhome.com/file/2023/2/a289202_0s.jpg)
谷歌Chrome浏览器在Win10预览版10525遇兼容性问题
![](https://img.aspxhome.com/file/2023/28/a248049_0s.jpg)
Excel数字如何添加单位
电脑版wps文档如何将页边距设置为书面装订样式
![](https://img.aspxhome.com/file/2023/6/a183366_0s.png)
excel中换行的技巧
xp系统开机不显示桌面怎么办?
![](https://img.aspxhome.com/file/2023/4/a304871_0s.jpg)
windwos8系统桌面图标太模糊变清晰的解决方法
![](https://img.aspxhome.com/file/2023/4/a308965_0s.jpg)