+ Reply to Thread
Results 1 to 4 of 4

VBA Loop to subtract values from stock quantity

  1. #1
    Registered User
    Join Date
    09-26-2016
    Location
    California, USA
    MS-Off Ver
    Standard 2013
    Posts
    8

    VBA Loop to subtract values from stock quantity

    I am trying to create an inventory sheet that has buttons to subtract a specified quantity from a stock quantity. There are different "builds" that require different inventory items, and I would like to be able to subtract the amount of inventory from the stock quantity for the specified build (See below):

    [Part #] [Description] [Stock Qty] [Build 1] [Build 2]
    1 _______ Screw _______ 20 _______ 2 ______ 1
    2 _______ Bolt ________ 20 ________ 1
    3 _______ Pipe ________ 10 _________________ 2

    So if I performed Build 1, there would be 18 screws, 19 bolts, and 10 pipes left. If I performed build 2 (from the same starting quantity), there would be 19 screws, 20 bolts, and 8 pipes. I have written out code for each item individually by referencing the exact cell using the following code:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The only problem is that there are over 100 inventory items on my spreadsheet and each time I change the location of something, I have to go in and update every cell reference (there are 6 "builds", so this is a lot). I am thinking there would be a way to loop through checking to see if there is anything in the "build" columns (D,E above) and somehow index that row to specify the correct stock quantity cell, but I'm a noob with VBA and can't seem to get anything to work.

    Thanks in advance for any guidance!

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: VBA Loop to subtract values from stock quantity

    Hi sam.schardt,

    Instead of code have a look at the attached (if I've understood correctly) where the closing stock level is determined simply by selecting an Y or N (cells D2:I2) if any of the six builds are being performed or not (respectively).

    HTH

    Robert
    Attached Files Attached Files
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    09-26-2016
    Location
    California, USA
    MS-Off Ver
    Standard 2013
    Posts
    8

    Re: VBA Loop to subtract values from stock quantity

    Hi Robert,

    Thanks for the response, the only problem is that these builds are constantly being performed. I.e., I may need to subtract five quantities at once, and be able to add in more inventory as it comes in and subtract more build quantities as the are performed.

  4. #4
    Registered User
    Join Date
    09-26-2016
    Location
    California, USA
    MS-Off Ver
    Standard 2013
    Posts
    8

    Thumbs up Re: VBA Loop to subtract values from stock quantity - SOLVED

    I figured out what I was trying to do. While the actual spreadsheet has many more items and products that are being built ("Builds"), here is a simple version that is based off of the example above:

    Please Login or Register  to view this content.
    This code would be assigned to a button for "Build 1". I then would have another set of code assigned to another button for "Build 2", which would reference column 5 in place of column for in the above code.

    I added in an input box since sometime we were building multiple quantities of a product at the same time. I hope someone else finds this useful!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Loop to subtract values from stock quantity
    By sam.schardt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2017, 08:16 PM
  2. Replies: 3
    Last Post: 04-22-2015, 04:02 PM
  3. [SOLVED] Help with VBA to Select next available quantity of stock. (FIFO)
    By JRidge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2014, 03:26 AM
  4. [SOLVED] Stock remarks depending on quantity
    By makinmomb in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-15-2014, 02:26 AM
  5. add, delete, update and add and subtract stock values..
    By djmag in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2013, 07:38 AM
  6. Replies: 4
    Last Post: 01-29-2013, 02:26 AM
  7. [Solved] Loop Through values until new value Appears, then Subtract
    By sgillette01 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-26-2012, 01:06 PM

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