简体   繁体   中英

Sum of ActiveCell.Offset Values

having issue with the below coding I'm putting in for a VBA macro.

Simply trying to sum 2 cells

ActiveCell.Offset(0, 4).Value = SUM(ActiveCell.Offset(-2, 4).Value):(ActiveCell.Offset(-1, 4).Value)

您添加的方法不是最好的方法,而只是回答您的问题,以下代码应该有效

ActiveCell.Offset(0, 4).Value = WorksheetFunction.Sum(Range(ActiveCell.Offset(-2, 4).Address & ":" & ActiveCell.Offset(-1, 4).Address))

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