Excel for Two-Sided Matching:
A Users’ Manual (short version 1)∗∗The original version of this note was written by Shuya Abe (Graduate School ofInformation Science, Osaka University) and Naoki Watanabe (Graduate School of Business
Administration, Keio University). The authors thank Jun Wako (Faculty of Economics,Gakushuin University) for his advice on software improvement.

11Introduction

This is a users’ manual (short version) for Excel for Two-Sided Matching tosolve two-sided matching problems with a computer. As of September 2017,
Excel for Two-Sided Matching version 3 (sample3.xlsm) is available from thefollowing URL.
http://labs.kbs.keio.ac.jp/naoki50lab/sample3.xlsm
The screen-shots in this manual were taken in the environment shown inTable 1.
Table 1: Environment of screen-shots
OSWindows 10 Enterprise
Excel
Microsoft Oﬃce 2016 Excel
CPUIntel(R) Core(TM) i7-3770K CPU @ 3.50GHz 3.90GHz
Memory
8 GB
Disk
1 TB

Excel for Two-Sided Matching runs on computers that can use Excel VBA(Visual Basic for Applications). The recommended environment is listed inTable 2.
Table 2: Recommended environment
OSExcelCPUMemory
Disk

Windows 7–，Mac OS X 10.8–
Microsoft Oﬃce 2013–，Microsoft Oﬃce for Mac 2016no requirement if Excel works
at least 2GB
no in particularNotes(1) Excel for Two-Sided Matching consists of 4 Excel sheets (man, group,conf, result) and 1 Visual Basic for Applications (VBA) program. If
assistance is needed for reading and writing VBA codes, refer to an
appropriate textbook.

2

(2) Two-sided matching is an assignment problem. Matching workers anddivisions in a company is an example, and the following information isused.
(a) Workers and divisions in a company: each worker has a preferenceover the divisions to which he or she is to be assigned, and eachdivision conducts evaluations of the workers. The preferences andevaluations are represented by ranking without ties.
(b) Quota: the maximal number of workers that can be accepted byeach division, i.e., capacity.
(3) Users need to input numerical values in Arabic numerals (not doublebyte characters) without multiple numbers and without missing
values for initial settings, workers’ preferences, divisions’ evaluations,and quotas of each division.
(4) Excel for Two-Sided Matching uses a program written in Visual Basic.
Thus, unlike editing a regular Excel sheet, users cannot restore states bypressing the “backspace” key or pressing the “Z” key while holding down
the “Ctrl” key. It is possible to return the Excel file to the intended state
before editing by closing the Excel file without saving the current state.
(5) The computation results are overwritten each time the program is run.
Thus, users need to make a copy of the computation results in anotherfile.

2Using Excel for Two-Sided Matching

2.1

Getting Started

Initially, set the numbers of workers and divisions in the VBA window. SeeFig. 1. By default, the number of workers is set as 107 and the number ofdivisions is set as 11.
1. Click on the Visual Basic button on the Developer ribbon.
2. Find VBAProject (sample3.xlsm) by Project explorer.
3. Open Module 1 in the Standard Module that is under
VBAProject (sample3.xlsm).

3Figure 1: Visual Basic window
4. Change the numbers in Const num man to set the number of workers,and change the numbers in Const num group to set the numbers ofdivisions. These are the first two lines in Module 1.
5. Save to the same file and close the Visual Basic window.

4

2.2

Running the Program

1. Complete the initial setting for the numbers of workers and divisions
in the Visual Basic window.
2. Input numerical data on workers’ preferences, divisions’ evaluation, andquotas in the (1) man sheet, (2) group sheet, and (3) conf sheet.
3. Open the (4) result sheet.
4. Choose one button out of three in the result sheet.
• Click on the da (man) button for computing a matching with theworker-proposing DA algorithm.
• Click on the da (group) button for computing a matching with thedivision-proposing DA algorithm.
• Click on the boston (man) button for computing a matching withthe worker-proposing DA algorithm.
5. View computation results in the result sheet.
(1) man sheet
Input workers’ preferences over divisions in Arabic numerals. See Fig.2,
where 20 workers all report their preferences over 5 divisions.
Rows in column A (man id): Input worker IDs in ascending order without multiple numbers and without missing values.
Rows in column B and thereafter (g rank): Each row is used for a worker.
Input the division ID worker i prefers at the jth rank in the cell corresponding to row (man id) i and column (g rank) j. (In Fig.2, thesecond-best division (g rank2) for a worker with ID=5 (man id=5) isa division with ID=4.) The value put in cell 6C is thus 4.
randomize button: Use this to generate the workers’ preferences randomly.

5Figure 2: man sheet

6(2) group sheet
Input divisions’ evaluations for workers in Arabic numerals. See Fig.3, where5 divisions report their evaluations for 20 workers (although the 13th ranked
worker and thereafter cannot be seen in the screen-shot).

Figure 3: group sheet
Rows in column A (group id): Input worker IDs in ascending order without multiple numbers and without missing values.
Rows in column B and thereafter (m rank): Each row is used for a division. Input the worker ID division i evaluates at the jth rank in thecell corresponding to row (group id) i and column (man rank) j. (InFig.2, the fourth-best worker (man rank4) for a division with ID=3
(group id=3) is a worker with ID=9.) The value put in cell 4E is thus
9.
randomize button: Use this to generate the workers’ preferences randomly.
7(3) conf sheet
Input quotas of divisions in Arabic numerals. See Fig.3, where 5 divisions
report 20 openings in total.

Figure 4: conf sheet

Rows in column A (group id): Input worker IDs in ascending order without multiple numbers and without missing values.
Rows in column B (max): Each row is used for a division. Input thequota of division i in the cell corresponding to “max” in row (group id).
The total of all quotas should coincide with the total numberof workers. In Fig.4, the quota of a division with ID=1 is 6. Thevalue put in cell 2B is thus 3.

8(4) result sheet
The computation results are shown in the result sheet. The buttons in thissheet are used to run each computation. See Fig.5, which shows a matchingof 20 workers to 5 divisions by rankings according to the workers’ preferences
and the divisions’ evaluations.

Figure 5: result sheet

Rows in column A (man id): Worker IDs are shown in ascending order.
Rows in column B (result group id): Each division matching each worker
is shown with the ID.
Rows in column C (last rank (man)): The rank of the division that matchesa worker in his or her preference is shown for each worker. In Fig. 5,worker 14 is matched with division 3, which is the 5th rank of his orher preference. The value put in cell 15C is thus 5.

9Rows in column E (group id): Division IDs are shown in ascending order.
Rows in column F (last rank (group)): The lowest rank of worker amongworkers matched with a division according to the division’s evaluation
is given. As shown in the middle of Fig.5, division 3 with quota 4 ismatched with the worker who is 20th in the evaluation of the division.
In division 3, no worker is lower ranked in the evaluation. The value
put in cell 4F is thus 20.
Row in column G (max): The quotas put in conf sheet are shown.
(Caveat) When the workers’ preferences have missing values, an error message appears if worker-proposing algorithms are used, whereas the divisionproposing DA algorithms may generate a matching. In the latter case, it
should be an error message if last rank (man)=0. The same thing
applies to the worker-proposing algorithms when the divisions’ evaluations
have missing values.
da (man)button: Press when worker-proposing DA algorithm is used.
da (group) button: Press when division-proposing DA algorithm is used.
boston (man) button: Press when worker-proposing Boston mechanism isused.
randomize man button: The same function button that appears in the mansheet.
randomize group button: The same function button that appears in the groupsheet.

10

3

Troubleshooting

3.1

Developer ribbon does not appear

In the default, Microsoft Oﬃce Excel does not show the Developer ribbon.
Complete the following procedure (in the case of Microsoft Oﬃce Excel 2016).
1. Click on the File ribbon.
2. Click on the Option ribbon.
3. Click on the Customize Ribbons in Excel’s Option window.
4. Confirm whether Main Tab appears in the Customize Ribbons
field, and then look for Developer in the list of ribbons in Main Tab.
5. Click on the OK button.
6. Close the Excel’s Option window, and then the Developer button
appears. If the button does not, then open the Excel file again.

3.2Error messages appear

Confirm the following points, when error messages appear after pressing thebuttons to run the program.
• Did you input data in Arabic numerals with single-byte characters inthe VBA window, man sheet, group sheet, and conf sheet?
• Do the numbers of workers and divisions initially set in the VBA window coincide with those put in man sheet and group sheet?
• Does the number of workers initially set in the VBA window coincidewith the total of all quotas put in conf sheet?

3.3

No error message but incorrect matching

Confirm the following points, when error messages appear but the software
does not generate a correct matching after pressing the buttons to run theprogram.
• Did you open your Excel file in Protected View (Fig.6)? In that case,click on the To Enable Editing button to end Protected View.
• Does the total of all quotas coincide with the total number of workers?
11• Are there any multiple numbers or missing values in man sheet, groupsheet, or conf sheet?

Figure 6: Screen-shot of Protected View.

12