+ Reply to Thread
Results 1 to 7 of 7

How to Keep value of sum after deleting integer

  1. #1
    Registered User
    Join Date
    03-30-2009
    Location
    Albuquerque, NM
    MS-Off Ver
    Excel 2007
    Posts
    3

    How to Keep value of sum after deleting integer

    I need help with what is probably a fairly easy VBA script, but i am new to VBA so, for lack of better words, I am stuck.

    What i need is a script that will add two boxes together to get a sum in a third box, but where it is tricky for me is that i need the third box to retain the summed value even when either of the first two box values are deleted.

    For example, say i have box A1=10, B1=40, and C1= SUM of A1 & B1 (so C1=50). Easy enough, but where im lost is that i want to be able to delete the value of either A1 or B1 and then have C1 still = 50, so then i can input another value into either A1 or B1 to continue to add to C1.

    I hope this I explained this halfway decent, and any help would be greatly appreciated!
    Last edited by ivander8; 03-31-2009 at 01:36 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: How to Keep value of sum after deleting integer

    See if this does what you want

    Right click sheet tab > select view code > paste in the below

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: How to Keep value of sum after deleting integer

    VBA Noob,
    I think the following line in your code

    HTML Code: 
    should be changed to

    HTML Code: 

    modytrane

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: How to Keep value of sum after deleting integer

    Thanks modytrane but I had assumed the OP want to add the C1 value instead of resetting to zero

    VBA Noob

  5. #5
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: How to Keep value of sum after deleting integer

    your code works fine with the change I suggested.
    If you enter a value in A1 and B1, C1 shows A1+B1.
    After that if you delete,A1 and/or B1 C1 retains the sum from previous run.
    If you enter new values in A1 and/or B1, C1 re-calculates the sum.

    At no point in this sequence, you would need to add C1 to itself.

    modytrane.

  6. #6
    Registered User
    Join Date
    03-30-2009
    Location
    Albuquerque, NM
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to Keep value of sum after deleting integer

    thanks for your help guys, its exactly what i need!

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: How to Keep value of sum after deleting integer

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1