+ Reply to Thread
Results 1 to 4 of 4

Formula or Macro to calculate combinations which produce whole numbers

  1. #1
    Registered User
    Join Date
    07-28-2010
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    91

    Formula or Macro to calculate combinations which produce whole numbers

    I have a dataset where there is a column which identifies certain records. i.e. the cell takes a value 1 if the record needs including and 0 if not.
    There is also a column which gives a number of parts needed. i.e. 1.56 or 2.73 etc.

    What I'm trying to do is split the records into batches of 4 to minimise wastage. So I need a formula or macro to look at the identifier column and then group together those records identified in the groups which minimise wastage according to the number of parts column.

    So ideally the output would be something like:

    group 1: A D E P
    group 2: B C F G

    etc...

    I'm sure this must be possible, but can't figure it out. Any help would be greatly appreciated.

    (this is similar to a previous post, but I have simplified the process as what I asked for before was overly complicated I think).

  2. #2
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Formula or Macro to calculate combinations which produce whole numbers

    This is called the bin packing problem and you would have to do it with VBA google the problem and there will be various tutorials.
    If someone helped give them rep using the star button.

    If you have received a satisfactory solution please mark the thread solved. If not Fotis will come for you at night :P

  3. #3
    Registered User
    Join Date
    07-28-2010
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Formula or Macro to calculate combinations which produce whole numbers

    Thanks for this. looks like a good place to start. I was thinking it would probably need VBA using a loop

  4. #4
    Registered User
    Join Date
    07-28-2010
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Formula or Macro to calculate combinations which produce whole numbers

    I'm still struggling on this. I can't modify the examples I can find on the bin packing problem online as they're all tailored to a given value as the decison criteria, whereas I'm looking for any whole number or closest value to a whole number.

    At the moment this looks to me to be unmanageable.

+ 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