简体   繁体   中英

Autofill One Cell VBA Excel

I am trying to autofill an equation only one column to the right of the active row and am having trouble. For example, there is an equation in I5, I want to have a macro that will auto fill J5 and only J5.

Thanks,

Becca

My deduction from your limited data is that you need the below solution. (Please do reply with details if you need more functionality than this.)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM