Formula to Evenly Distribute Guests on a Seating Plan

markmogli

New Member
Joined
Dec 20, 2019
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a spreadsheet where column A has the company name and column B has the total guests booked to attend the event. I need to allocate the guests to tables where the smallest can be a table of 7 and the largest can be a table of 14. I also need to allocate the party to the smallest number of tables possible.

A party of 15 guests will be seated as 1 x table of 7 and 1 x table 8.


A party of 20 guests will be seated as 2 x tables of 10.


A party of 36 guests can be seated as either

3 x tables of 12

or

1 x table of 13, 1 x table of 12 and 1 x table of 11


A party of 100 guests can be seated as:

10 tables of 10

but they could also be seated as:

6 x tables of 14 and 2 x tables of 8


I have 2,200 guests to seat and a maximum of 220 tables. I want the least possible tables and as bonus points, I only have 30 tables which will take 13 or 14 guests, the other 190 tables seat a max of 12.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I don't see why this is a problem, let alone an Excel problem. Do you have some other constrains you did not say, e.g. maximizing the number of people from the same company in the same table together?

Let's say the 30 big tables can each seat 14 people. You fill them up first. you would have 420 less (2200-420=1780) people to consider. The 1780 people would take 148 tables with four people in another table (1780/12 = 148 with a remainder of 4). Since the minimum size of guests in a table is 7, the 1780 people would take 147 tables of 12 and two tables of 8. This way, you'd need 30 + 147 + 2 = 179 tables.
 
Upvote 0
I was also thinking that this could be quickly solved using the same logic described in the previous post. Since you want the least number of tables to be used, its pretty clear that you just fill up the 30 tables with 14 guests, then fill up the remaining tables with 12 guest until you have less than 12 guests. Then fudge the remainder (take back 12 people from one of the tables and split them with the last 4 people to make two tables of 8).

As an excel problem this could be set up as a solver problem. But that is not something that can be explained in a post - you would want to google "Excel Solver" or "Excel solving minimization problems with constraints" or "Excel solving maximization problems with constraints". These or similar searches should set you up with some tutorials and examples. It's the kind of thing that you have to invest some time in learning first. But it's overkill in this particular case since the minimization is easily determined with just a few operations (fill up the tables with max guests until you run out of guests or tables, the only trick being at the end you might have to split guests into the two last tables in a balanced manner (two tables of 8 rather than one of 12 and one of 4).
 
Upvote 0
The basic algorithm described above is certainly a starting point, but it's surprisingly tricky in the details. Here's what I came up with:

Book1
ABCD
1Number of guests# of 14-guest tables# of 12-guest tables
27230190
3
4Minimum # of tables
56
6Option 2 (average a 14-person table with the smallest table)
7Table sizeCount
81454
913 0
1012 0
1111 0
1210 0
139 0
148 2
157 0
166 0
175 0
184 0
193 0
20210
211 0
22
23Total guests:7272
24Total tables66
Sheet13
Cell Formulas
RangeFormula
A5A5=IF(A2<=14*C2,ROUNDUP(A2/14,0),C2+ROUNDUP((A2-C2*14)/12,0))
B8B8=IF(A2>=C2*14,C2,INT(A2/14))
B9B9=IF(AND(B8<C2,MOD(A2,14)=13),1,"")
B10B10=IF(A2>C2*14,INT((A2-C2*14)/12),IF($A$2-SUMPRODUCT($A$8:$A$9,$B$8:$B$9)=A10,1,""))
B11:B21B11=IF($A$2-SUMPRODUCT($A$8:$A$10,$B$8:$B$10)=A11,1,"")
D8:D21D8=IF($A$2<15,"",N(B8)-(A8=LOOKUP(999,$B$8:$B$21,$A$8:$A$21))-(A8=14)+(ROUNDUP((14+LOOKUP(999,$B$8:$B$21,$A$8:$A$21))/2,0)=A8)+(ROUNDDOWN((14+LOOKUP(999,$B$8:$B$21,$A$8:$A$21))/2,0)=A8))
B23B23=SUMPRODUCT(A8:A21,B8:B21)
B24, D24B24=SUM(B8:B21)
D23D23=SUMPRODUCT(A8:A21,D8:D21)


I've tested this a lot, and I think it works, but it's very possible I missed a case. This case here shows the results of 72 guests. The first pass shows 5 14-person tables and 1 2-person table. Averaging a full table with the remainder comes up with 4 14-person tables, and 2 8-person tables. Better, but better still would be 6 12-person tables.

Or consider 18 guests. Option 1 has 14 and 4, option 2 has 9 and 9. Option 1 has a large disparity in size. And if the event has people coming in couples, then option 2 doesn't work well either. 2 tables of 8 and 10 might be best.

And for larger groups, like the 2200 mentioned? At that size, I'd say the odds of some people not showing up is pretty high. I'd probably round up to the next full table size. Let the guests figure out where to sit.

In any event, I doubt there's an ideal algorithm that takes in to account every situation, but this could be a good starting point.
 
Upvote 0
Solver doesn't really come up with the best solutions in my testing. Especially since we don't know if there are any other factors. For example, maybe the big tables cost more than the smaller tables.

Either way, the only other combination that seems viable is 153 12-seat tables and 26 14-seat tables.
 
Upvote 0
I don't see why this is a problem, let alone an Excel problem. Do you have some other constrains you did not say, e.g. maximizing the number of people from the same company in the same table together?

Let's say the 30 big tables can each seat 14 people. You fill them up first. you would have 420 less (2200-420=1780) people to consider. The 1780 people would take 148 tables with four people in another table (1780/12 = 148 with a remainder of 4). Since the minimum size of guests in a table is 7, the 1780 people would take 147 tables of 12 and two tables of 8. This way, you'd need 30 + 147 + 2 = 179 tables.

Sorry, yes, the constraint is that all guests from each company must sit together - there can be no mixed tables.
 
Upvote 0
The basic algorithm described above is certainly a starting point, but it's surprisingly tricky in the details. Here's what I came up with:

Book1
ABCD
1Number of guests# of 14-guest tables# of 12-guest tables
27230190
3
4Minimum # of tables
56
6Option 2 (average a 14-person table with the smallest table)
7Table sizeCount
81454
913 0
1012 0
1111 0
1210 0
139 0
148 2
157 0
166 0
175 0
184 0
193 0
20210
211 0
22
23Total guests:7272
24Total tables66
Sheet13
Cell Formulas
RangeFormula
A5A5=IF(A2<=14*C2,ROUNDUP(A2/14,0),C2+ROUNDUP((A2-C2*14)/12,0))
B8B8=IF(A2>=C2*14,C2,INT(A2/14))
B9B9=IF(AND(B8<C2,MOD(A2,14)=13),1,"")
B10B10=IF(A2>C2*14,INT((A2-C2*14)/12),IF($A$2-SUMPRODUCT($A$8:$A$9,$B$8:$B$9)=A10,1,""))
B11:B21B11=IF($A$2-SUMPRODUCT($A$8:$A$10,$B$8:$B$10)=A11,1,"")
D8:D21D8=IF($A$2<15,"",N(B8)-(A8=LOOKUP(999,$B$8:$B$21,$A$8:$A$21))-(A8=14)+(ROUNDUP((14+LOOKUP(999,$B$8:$B$21,$A$8:$A$21))/2,0)=A8)+(ROUNDDOWN((14+LOOKUP(999,$B$8:$B$21,$A$8:$A$21))/2,0)=A8))
B23B23=SUMPRODUCT(A8:A21,B8:B21)
B24, D24B24=SUM(B8:B21)
D23D23=SUMPRODUCT(A8:A21,D8:D21)


I've tested this a lot, and I think it works, but it's very possible I missed a case. This case here shows the results of 72 guests. The first pass shows 5 14-person tables and 1 2-person table. Averaging a full table with the remainder comes up with 4 14-person tables, and 2 8-person tables. Better, but better still would be 6 12-person tables.

Or consider 18 guests. Option 1 has 14 and 4, option 2 has 9 and 9. Option 1 has a large disparity in size. And if the event has people coming in couples, then option 2 doesn't work well either. 2 tables of 8 and 10 might be best.

And for larger groups, like the 2200 mentioned? At that size, I'd say the odds of some people not showing up is pretty high. I'd probably round up to the next full table size. Let the guests figure out where to sit.

In any event, I doubt there's an ideal algorithm that takes in to account every situation, but this could be a good starting point.


I think this might of use to me. Here is what I have. As you can see, a company with 60 guests can be seated two ways. Bookings can be from just 7 guests or 267 guests. I'm currently manually deciding how best to allocate each company.

Book1
ABCDEFGHIJKLMNOPQ
11st set2nd set3rd setGuest SumTable Sum
2CustomerGuestsNo of.GuestsNo of.GuestsNo of.GuestsGuest SumCheckTable Sum
3Company 1119111019119True12
4Company 29199True1
5Company 36061060True6
6Company 46051260True5
7Company 515 False0
8Company 616 False0
9Company 712 False0
10Company 819 False0
11Company 929 False0
12Company 1019 False0
13Company 119 False0
14Company 1210 False0
15Company 1311 False0
16Company 1426 False0
17Company 1514 False0
Sheet1
Cell Formulas
RangeFormula
N3:N17N3=IF(((E3*F3)+(H3*I3)+(K3*L3))=0,"",(E3*F3)+(H3*I3)+(K3*L3))
O3:O17O3=EXACT(C3,N3)
Q3Q3=(E3+H3+K3)
Q4:Q17Q4=E4+H4+K4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L3:L109Cell Value=7textNO
L3:L109Cell Value=8textNO
L3:L109Cell Value=9textNO
L3:L109Cell Value=10textNO
L3:L109Cell Value=11textNO
L3:L109Cell Value=12textNO
L3:L109Cell Value=13textNO
L3:L109Cell Value=14textNO
I3:I109Cell Value=7textNO
I3:I109Cell Value=8textNO
I3:I109Cell Value=9textNO
I3:I109Cell Value=10textNO
I3:I109Cell Value=11textNO
I3:I109Cell Value=12textNO
I3:I109Cell Value=13textNO
I3:I109Cell Value=14textNO
F3:F109Cell Value=7textNO
F3:F109Cell Value=8textNO
F3:F109Cell Value=9textNO
F3:F109Cell Value=10textNO
F3:F109Cell Value=11textNO
F3:F109Cell Value=12textNO
F3:F109Cell Value=13textNO
F3:F109Cell Value=14textNO
Q3Expression=Q3=AQ3textNO
N3:N109Expression=N3=C3textNO
O3:O110Cell Valuecontains "true"textNO
 
Upvote 0
And the final part of allocating the tables:

Book1
UVWXYAQAXAYAZBA
112345To be printed on the night
21st table2nd table3rd table4th table5th tableTotal TablesTable NumbersTable BreakdownTotal No. of Tables
311912012112212351.1912E+1411x10,1x95
412711271x91
512612913313413551.26129E+146x105
60 5x120
70  0
80  0
90  0
Sheet1
Cell Formulas
RangeFormula
AQ3:AQ9AQ3=COUNTIF(U3:AN3,"<>")
AY3:AY9AY3=SUBSTITUTE(TRIM(U3&" "&V3&" "&W3&" "&X3&" "&Y3&" "&Z3&" "&AA3&" "&AB3&" "&AC3&" "&AD3&" "&AE3&" "&AF3&" "&AG3&" "&AH3&" "&AI3&" "&AJ3&" "&AK3&" "&AL3&" "&AM3&" "&AN3)," ",",")
AZ3:AZ9AZ3=SUBSTITUTE(TRIM(AR3&" "&AS3&" "&AT3)," ",",")
BA3:BA9BA3=AQ3
 
Upvote 0
You can give this VBA solution a shot. Seems to work pretty well.

Book1
ABCDEFGHIJKLMNOP
1Table Size
2CompanyGuestsMax67891011121314Guest CountDiffTable Count
3Company A312220002000021312023
4Company B180120000001012180013
5Company C140100000000010140010
6Company D200140002000013200015
7Company E188131000000013188014
8Company F1289002000008128010
9Company G364260000000026364026
10Company H268190020000018268020
11Company I220150000100015220016
12Company J200140002000013200015
13Totals:22000162
Sheet5
Cell Formulas
RangeFormula
N3:N12N3=SUMPRODUCT($E$2:$M$2*E3:M3)
O3:O12O3=$B3-N3
P3:P12P3=SUM(E3:M3)
N13:P13N13=SUM(N3:N12)
A3:A12A3="Company " & CHAR(ROW()+62)
C3:C12C3=ROUNDDOWN(B3/14,0)


VBA Code:
Sub TABLEORG()
Dim AR() As Variant: AR = Range("A3:C" & Range("A" & Rows.Count).End(xlUp).Row).Value
Dim dif As Integer: dif = 0
Dim total As Integer: total = 0

Range("M3:M" & UBound(AR) + 2).Value = Range("C3:C" & UBound(AR) + 2).Value

For i = 1 To UBound(AR)
    If AR(i, 2) < 14 Then
        Cells(i + 2, AR(i, 2) - 1).Value = 1
    Else
        total = AR(i, 3) * 14
        dif = AR(i, 2) - total
        If dif > 0 Then
            If dif >= 6 Then
                Cells(i + 2, dif - 1).Value = 1
            Else
                With Cells(i + 2, 13)
                    .Value = .Value - 1
                End With
                dif = (dif + 14) / 2
                Cells(i + 2, dif - 1).Value = 2
            End If
        End If
    End If
Next i
End Sub
 
Last edited:
Upvote 0
Had to update the code a bit. This code should be better.

VBA Code:
Sub TABLEORG()
Application.ScreenUpdating = False
Dim AR() As Variant: AR = Range("A3:C" & Range("A" & Rows.Count).End(xlUp).Row).Value
Dim dif As Integer: dif = 0
Dim total As Integer: total = 0

Range("M3:M" & UBound(AR) + 2).Value = Range("C3:C" & UBound(AR) + 2).Value

For i = 1 To UBound(AR)
    If AR(i, 2) < 14 Then
        Cells(i + 2, AR(i, 2) - 1).Value = 1
    Else
        total = AR(i, 3) * 14
        dif = AR(i, 2) - total
        If dif > 0 Then
            If dif >= 6 Then
                Cells(i + 2, dif - 1).Value = 1
            Else
                With Cells(i + 2, 13)
                    .Value = .Value - 1
                End With
                
                If dif Mod 2 = 0 Then
                    dif = (dif + 14) / 2
                    Cells(i + 2, dif - 1).Value = 2
                Else
                    dif = Application.WorksheetFunction.RoundDown((dif + 14) / 2, 0)
                    Cells(i + 2, dif - 1).Value = 1
                    Cells(i + 2, dif).Value = 1
                End If
            End If
        End If
    End If
Next i
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,236
Messages
6,123,799
Members
449,127
Latest member
Cyko

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top