+ Reply to Thread
Results 1 to 13 of 13

Add or subtract from total

  1. #1
    Registered User
    Join Date
    05-20-2005
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    Office 2003
    Posts
    7

    Add or subtract from total

    Hi there, I need help with an inventory spreadsheet I'm trying to create. Here's the scenerio.

    CELL A1=45

    I want CELL A2 to be a blank cell which people can enter a number in that will decrease the value of A1 and once that value is entered, it would return to a blank cell. CELL A3 would be used in the same fashion except to increase the value of A1

    what would a formula for this look like?

    thanks much!
    John
    Last edited by John Mathieson; 02-21-2010 at 07:19 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Add or subtract from total

    This is a VBA question. Are you OK with turning on macros on your workbook? If so:

    1) Right-click on the sheet tab and select VIEW CODE
    2) Paste in this sheet-event macro to the window that appears:
    Please Login or Register  to view this content.

    3) Close the editor and save your workbook (as a macro-enabled workbook if you're using Excel 2007...please fill out your profile)


    Try changing values in A2 and A3.
    Last edited by JBeaucaire; 02-20-2010 at 02:48 PM. Reason: Code tweaked, d/l again if needed
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-20-2005
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    Office 2003
    Posts
    7

    Re: Add or subtract from total

    thanks for the quick reply...My first attempt at VB so this should give me some good experience!..

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Add or subtract from total

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)

  5. #5
    Registered User
    Join Date
    05-20-2005
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    Office 2003
    Posts
    7

    Re: Add or subtract from total

    Thanks, initially I didn't think this was a VB thing, just a formula..Maybe I'm getting in over my head but I need to calculate more cells in the same sheet, so I tried to copy the code and change the values to the cells I need but I kept getting errors "ambigious name detected" or it just didn't work at all...Here's what I tried..How would i add more cells onto this subroutine?

    Please Login or Register  to view this content.
    Last edited by John Mathieson; 02-21-2010 at 10:15 AM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Add or subtract from total

    John, be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to edit that post above and put code tags around that code you used. (Like I did in my posts...) Look in my signature for an example of how to wrap the code in tags.

    Go ahead and fix that then I'll show you how to get multiple events into the one ws_change macro.

  7. #7
    Registered User
    Join Date
    05-20-2005
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    Office 2003
    Posts
    7

    Re: Add or subtract from total

    Thanks Jerry, I can appreciate those rules. I have made the changes and look forward to your reply!...John.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Add or subtract from total

    Here you go: Adjust the range as needed:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-20-2005
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    Office 2003
    Posts
    7

    Re: Add or subtract from total

    Thanks Jerry that works great, I'm almost there!...I just need one more adjustment. I also have items in Column H with the inputs in Column E and F and an Items in Column L with the inputs in Column I and J and so on.

    So I'm good for the Items in Column D, the inputs are column A and B cells 10-15. How can reproduce this for items to the right? thanks for all the help, I'm learning lots so far!..

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Add or subtract from total

    I'm surprised you didn't at least try to add the new sections into the code, it's nothing more than a cut-n-paste job/change the ranges...

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 02-21-2010 at 04:00 PM.

  11. #11
    Registered User
    Join Date
    05-20-2005
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    Office 2003
    Posts
    7

    Re: Add or subtract from total

    Thanks Jerry, I tried copying and pasting but I think I missed something..This is my first experience with VB so everything is new, thanks for all the help!

  12. #12
    Registered User
    Join Date
    06-23-2014
    Location
    shanghai, china
    MS-Off Ver
    0ffice 2007
    Posts
    1

    Re: Add or subtract from total

    Hi Jerry,

    My name is Simon and I'm brand new to the forum and Excel. I'm trying to set up an inventory sheet nearly exactly like John's with a row showing the total inventory (row c) then a row to show outgoing (row H) and a row to show incoming (row I). The only difference with John's (I think) is I want the values in Row H and I to stay visible. I used the formula for the single cells you originally posted and it worked perfectly but the VB for a range of cells isn't working for me. I modified it slightly for my purposes so maybe I'm went wrong somewhere. Below is the code i put in. Could you have a look and advise if I made any mistakes? Cheers!

    Please Login or Register  to view this content.

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,969

    Re: Add or subtract from total

    Hi Soso277B and welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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