+ Reply to Thread
Results 1 to 4 of 4

Excel Function or VBA

  1. #1
    Registered User
    Join Date
    01-07-2020
    Location
    Canada
    MS-Off Ver
    QC
    Posts
    5

    Excel Function or VBA

    Hi All,

    Im currently working on a software in excel for work. I having trouble making the following work.

    Cell 1 Box Width 48 (width from outer shell to outer shell)
    Cell 2 (24x24 square) 1 Quantity
    Cell 3 (12x24 square) 1 Quantity

    Problem:
    I have a square objects that will be placed into a box. The square objects are 24"x24" and 12"x24". My box is 48"W x 39"H. (kind of like placing boxes onto a palette, how many can you fit in each direction)

    I want to Calculate how many 24x24 and 12x24 I can fit in this box will fit into this box.
    I've attached a drawing onto this post (hopefully it worked)

    Please let me know if you need any more information. I am struggling with this, so any help will be much appreciated

    josh
    Attached Images Attached Images

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel Function or VBA

    Is this an absolute example or are you wanting to generalise the solution for combinations of different box sizes.

    Trivially in this case of course and merely by imagining the placements you can fit two of the 24 x 24 boxes and two of the 24 x 12 boxes. Leaving 144 sq.units unused
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,701

    Re: Excel Function or VBA

    By inspection, you can see that you can fit 2 of the larger boxes (24"x24") side-by-side horizontally, which will leave you with 15"x48" to be filled. If you turn your smaller box through 90 degrees, you can also fit two of these in that remaining space, with a gap of 3"x48" remaining.

    Hope this helps.

    Pete

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,810

    Re: Excel Function or VBA

    This appears to be a fairly typical packing problem. Packing problems are fairly common in math and computer science discussions, and they are fairly difficult to program (especially if you want to program them efficiently).:

    https://en.wikipedia.org/wiki/Packing_problem
    http://mathworld.wolfram.com/Bin-PackingProblem.html
    a link in the wikipedia page leads here: https://www.codeproject.com/Articles...gorithm-for-bu

    or, if you use a different visualization for the problem -- instead of packing smaller rectangles within a larger rectangles visualize cutting smaller rectangles from a larger rectangle -- and you end up with the (2D) cutting stock problem. You may find this old discussion thread interesting: https://www.mrexcel.com/board/thread...6/#post-327860

    Most of these problems reduce to the knapsack problem which is NP-hard/NP-complete -- meaning that there just are not efficient algorithms for getting a rigorous solution. Most Excel/spreadsheet based solutions that I see involve Solver. The programmer works out a way to describe the arrangement of rectangles within the larger rectangle (I don't have any specific ideas, yet for this, but the codeproject link above describes a way) then compute "waste" (or other optimization parameter). Then call Solver and tell it to optimize "waste" by changing "arrangement of rectangles". Then see what Solver comes up with.

    One idea that might simplify this particular problem. Two 12x24 rectangles side by side make up one 24x24 rectangle. It might be easier to solve the problem for the 12x24 rectangles alone. Then look at that solution and recognize that any two 12x24 adjacent rectangles can be replaced with one 24x24.

    It is a challenging problem -- especially if it is one that you have not tackled before. Study some of these and see if they help. Then let us know how you decide to proceed and how we can help you implement your chosen algorithm.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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. COUNTUNIQUE Function in Google Sheets; Excel lacks a direct counterpart to this function?
    By PivotTablePSHomage in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2018, 05:27 AM
  2. Excel VBA Function Method API Windows Function User32.dll Alias Declare Library List . :)
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2018, 07:51 PM
  3. Replies: 4
    Last Post: 04-24-2014, 11:56 AM
  4. Replies: 13
    Last Post: 04-08-2014, 05:46 AM
  5. Replies: 1
    Last Post: 03-21-2012, 11:22 AM
  6. Replies: 2
    Last Post: 03-30-2009, 04:04 AM
  7. [SOLVED] Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 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