首页 > 解决方案 > 自动填充一个单元格 VBA Excel

问题描述

我正在尝试仅在活动行右侧的一列中自动填充方程式,但遇到了麻烦。例如,I5 中有一个方程,我想要一个宏来自动填充 J5,并且只填充 J5。

谢谢,

贝卡

标签: vbaexcel

解决方案


我从您有限的数据中推断出您需要以下解决方案。(如果您需要更多功能,请回复详细信息。)

Public Sub FormulaPopulation()


Dim rng1 As Range
Dim rng2 As Range

Set rng1 = Sheet1.Range("J2")   ' Have assumed over here that the formula that you need autofilled is in "J2" which is an unrelated cell
Set rng2 = Sheet1.Range("J5")   ' Then since you only need this cell filled we take this cell.

rng2.Formula = rng1.Formula     ' Finally it is formula matched, rather than Autofilling. Much faster than autofill.


End Sub

推荐阅读