简体   繁体   中英

Excel VBA Macro - Execute Formula using value of a cell in one location

I am new to VBA and was trying to write a macro for some calculations. One of the calculations involves reading in data from a particular location (R2C2 for example) and using a formula to compute a value stored in the adjacent column (R2C3 in this example).

I have this line: ActiveSheet.ActiveSheet.Cells(row_number, Col + 1).Formula = "=ActiveSheet.Cells(row_number, Col).Value + 10"

But it does not seem to work and I am not sure why. Everything I have searched for uses Range but I am not sure how to use Range when I am referencing my cells using Row, Column notation instead of A1/B1 notations.

Any help would be great - Thanks

这是制作公式的方法:

ActiveSheet.Cells(row_number, Col + 1).Formula = "=" & Cells(row_number, Col).Address & "+10"

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