subtracting 2 values [SOLVED]

  • that doesn't seem to work, i want to be able to continue deducting the £500 on the dept budget worksheet through the C++ programmer claim button, the value which gets stored in the CLAIM TOTAL cell at the moment it's £460 should get taken away from the £500 value in the dept budget worksheet in cell "g8".


    Any help would be appreciated

  • Hi, do I have this right?
    You need VBA code as follows:
    Dept budget is $500 (or whatever). Each time the Claim Button is pressed it deducts the current claim $X from the remaining dept budget?

  • Range("L29").Select
    Selection.Copy
    Sheets("Department Budget").Select
    Range("j8").Select
    ActiveSheet.Paste
    Range("g8").Select
    ActiveCell.FormulaR1C1 = ("=RC - RC[3]")


    i tried this code so as to copy the value into the same worksheet and then carry out the calculation there but the £500 just turns to 0:puzzled:

  • rather than paste why not try


    Selection.PasteSpecial Operation:=xlAdd


    which will continue to increase the claim rather than mearly overwriting the current value?

  • Sorry.. forgot that bit just where you had paste before, everything else remains the same.



    Range("J8").Select


    Selection.PasteSpecial Operation:=xlAdd


    Range("h8").Select


    Hope this helps

  • Seems to work fine for me, I've added another module (option b) which does what I think you want on one line.


    Keep me posted!
    '''''Option a
    Sub cplus()
    '
    ' cplus Macro
    ' Macro recorded 06/04/2003 by NAMELESS
    '


    '
    Range("L29").Select
    Selection.Copy
    Sheets("Department Budget").Select
    Range("J8").Select
    Selection.PasteSpecial operation:=xlAdd
    Range("h8").Select
    ActiveCell.FormulaR1C1 = "=RC[-1]-RC[2]"


    End Sub


    '''''''OptionB
    Sub newsubtract()
    Sheets("Department Budget").Range("j8").Value = Sheets("Claim Form").Range("L29").Value + Sheets("Department Budget").Range("j8").Value
    End Sub

  • Thanx a lot m8, really appreciate it.
    option B works well, i just subtracted that value from the £500 budget and it calculates the current amount:yes:
    thanx again

Participate now!

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