简体   繁体   中英

Adding Sum value to active cell VBA excel

Im trying to add a sum into an active cell but its still not working.

My code:

rngCell2.Offset(0, 6).Activate
ActiveCell = ActiveCell + 15

When the cell is empty, after execute the cell will get value 15. But when there is already a number fe 60, it stays 60.

What is wrong in my code, what is the correct code?

thanks in advance

Try

rngCell2.Offset(0, 6).Value = rngCell2.Offset(0, 6).Value + 15

This will increase the cell that is 6 columns to the left of rngCell2 by 15.

If you just need to increase the ActiveCell, try

ActiveCell.Value = ActiveCell.Value + 15

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