Auto Add/Subtract

  • Hi all,

    Hope everyone is keeping well!

    Im not sure if a code or formula is required. What im looking to do is when i have a value in cell a1, if i type a value into cell a2, it will automatically add that value to cell a1. It will then clear the cell a2 ready for the next time a value is typed in it.

    Any help would be appreciated!

  • must be done by vba

    right-click on sheet tab \ View Code \ paste code into the code window

  • Try this

  • Thanks for your help, if i wanted to make this the case for section J8:400, so when you type in any cell in J8:400, it will add/subtract to the one beside it. So typing in J8 would add/subtract from I8, typing in J50 would add/subtract from I50 and so on

  • Hi Roy,

    I thought i provided the information required i do apologize. It would need to do both, so if i type in 500 it would add, if i typed in -500 it would subtract as it would be trying to add a negative?

    You would be typing in J8:40, and it would be adding/subtracing from the cell to the left. (i8:400)

    Please let me know if you are on the same wave length!

  • Try this

  • or this :)

  • Mine definitely clears the cell that you enter into.

    The other advantage with my code is that it only allows one cell to be used at a time

  • The codes are almost identical and both clear the cell (with Target.ClearContents)

    The cell is not being cleared in YOUR workbook which suggests that something else is going on, that we are unaware of.

    1. Are the macros installed EXACTLY as posted ?

    2. Are any other event macros acting on your workbook ?

    If nothing is obvious to you, create a new workbook with only ONE sheet

    - test each one of the event macros in turn

    - do nothing other than amending values in J8:J400

    - I expect both macros to clear the cell

    - After that, look at your workbook and work out what is different

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!