+ Reply to Thread
Results 1 to 2 of 2

How would I implement this optimization using Excel?

  1. #1
    Registered User
    Join Date
    11-20-2020
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    3

    How would I implement this optimization using Excel?

    I have this optimization problem that I would like to solve, but I have no idea how to go about it as my knowledge in VBA is very very basic. So I have multiple selection checkboxes which when checked populate a cell, like so:
    p1.png
    What I would like to achieve is similar to a cash withdrawal system from a bank, where when you select the amount you want, it automatically populates the number and the value of cash you'd like. For example, if you wanted to withdraw $100, it could say give you 2 x $20, 1 x $10 and 1 x $50, and when you deselected and amount, other amounts would increase to match $100.

    In my case, when the fields "Drilled Hole Volume" and "Volume of Bolt" are populated, I'd like for the macro to look into the following data values:
    p2.png
    Then I would like it to choose a maximum of 2 cartridges that will populate the cell for the field "Volume of Cartridges" so that the field "Remaining Volume" becomes very close to zero. I would also like the macro to populate the "Quantity" field in image 1 and update the "Cartridge" ActiveX ListBox with the proper selection.

    When someone clicks the down arrow, the macro would recalculate what the next best value that would result in 0 being and fill the "Quantity" field and update the "Cartridge" ActiveX ListBox again. In the event that someone can enter 2 of the same kind, but the "Remaining Volume" value does not go to zero, then it won't let them do it. However if the value becomes close to being 0, it will let them choose 2 of the same kind. So the process would look something like this.

    1) I select my options using the checkboxes I have:
    p9.png
    2) Then, the macro would automatically populate its best options that would result in the values being close to 0 and fill the "Quantity" field, update the ListBox and populate the cell "Cartridge". For example, the quantities for 28mm Dia. x 24" and 25mm Dia. x 12" are 1 each, and their added volumes is 31.44, and with my other selections, the "Remaining Volume" cell becomes 0.37 which is negligible and round able to 0:
    p10.png
    3) When I hit up for the same parts, but the values become negative, then I would get a popup that says "Invalid selection": (Can't show this yet).

    4) When I hit down, the macro will recalculate the next best option that will result in the value "Remaining Volume" getting closest to 0, and then show it again like so:
    p11.png
    The value for the field "Remaining Volume" is 1.450. This is also negligible. The range of negligible values is 0 - 1.8.

    Any help or guidance would be greatly appreciated.
    Last edited by Ayugma Achaeya; 12-09-2020 at 11:46 AM. Reason: Attaching a file

  2. #2
    Registered User
    Join Date
    11-20-2020
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    3

    Re: How would I implement this optimization using Excel?

    I forgot to attach the excel file. Sorry
    Attached Files Attached Files

+ 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. How to implement a Gompertz curve in Excel?
    By rfeu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2016, 03:09 AM
  2. How to implement this situation on excel
    By moshwad in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-13-2014, 01:39 PM
  3. [SOLVED] implement the simple excel formula using vba
    By kate.middleton1 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-06-2012, 12:24 PM
  4. Implement back end DB whien using excel as front end DB
    By Snoopy2003 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-30-2012, 06:39 PM
  5. How to implement this vb code in my excel doc?
    By Call in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-28-2010, 06:48 AM
  6. [SOLVED] How do I,implement a recurssive loop using Microsoft Excel ?
    By Vikas_Yadav in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2005, 03:05 AM
  7. How to implement a if-else structure in excel?
    By aijihz in forum Excel General
    Replies: 0
    Last Post: 03-10-2005, 03:10 AM

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