excel - VBA自动填充两列的最后一行
解决方案
两个部分:
- 获取对要复制的公式的引用和要填充的区域
- 复制公式
查看内联注释
Sub Demo()
Dim rFormulaToCopy As Range
Dim FormulaColumn As Long, NumOfFormula As Long
Dim DataColumn As Long
'~~~ update to match your sheet layout
FormulaColumn = 4
NumOfFormula = 2
DataColumn = 1
With ActiveSheet '~~~ specify the required sheet
' Reference the last row of Formula
Set rFormulaToCopy = .Cells(.Rows.Count, FormulaColumn).End(xlUp).Resize(, NumOfFormula)
' Reference the missing formula range, including the last Formula row.
' Assign from/to the Formula property to copy formulas (Excel will update relative references)
rFormulaToCopy.Resize(.Cells(.Rows.Count, DataColumn).End(xlUp).Row - rFormulaToCopy.Row + 1).Formula = rFormulaToCopy.Formula
End With
End Sub
推荐阅读
- sql - 如何在 where 查询中使用 postgres 数组?
- node.js - 从 Lambda 中的 NodeJS 流中提取数据时遇到问题
- d3.js - d3.js 难度渲染条形图代码取自 bl.ocks 示例
- python - 如何在安装中包含 Python 2.x 二进制文件
- linux - 用于重新启动 apache 服务器的 Cron 脚本不起作用
- android - 在我的虚拟设备上运行我的颤振应用程序
- python - 按照列表中值的顺序过滤已排序的 NumPy 数组的行
- c# - 将未知参数添加到泛型方法内的 Func
- reactjs - mapDispachToProps 在触发事件 onChange 函数时出错
- javascript - Child.html:28 错误类型错误:无法读取未定义的属性“推送”