VBA & Macro Problems

How to Find Excel Number Combinations That Equal a Target Sum

Camila MilosovichCamila Milosovich Oct 23, 2026 874 views

Question details

The user needs to identify which specific numbers from a given list add up to a desired target total.

How to Find Excel Number Combinations That Equal a Target Sum
Product
Excel
Device & OS
not provided
Scenario
Performing financial reconciliation, invoice matching, or mathematical problem solving where a subset of values must precisely match a known total.
Observed behavior
The user wants to find matching combinations but notes that the Goal Seek feature is unsuitable because it only alters one variable. They require a method using Solver or VBA that handles multiple selections simultaneously.
Before you start

Ensure you have the Solver Add-in enabled by navigating to File > Options > Add-Ins. If you plan to use the macro method, verify that the Developer tab is visible on your Excel ribbon.

Solution 1Recommended

Use the Excel Solver Add-in to Find a Single Combination

The Solver add-in is ideal for smaller lists of numbers. By using binary variables (0 or 1), Solver can quickly identify one specific combination that adds up to your target value.

This method requires setting up an adjacent column to act as a multiplier (0 means the number is excluded, 1 means it is included) and using a SUMPRODUCT formula to calculate the total of the selected numbers.

1
Set up your data and multiplier column

List your numbers in column A (e.g., A2:A20). In column B (B2:B20), enter the number 0 next to each value. This will be your changing variable column.

2
Create a SUMPRODUCT formula

In an empty cell (e.g., C2), enter the formula =SUMPRODUCT(A2:A20, B2:B20). This cell will display the current sum based on the 0 or 1 multipliers.

3
Open the Solver Add-in

Go to the Data tab on the Excel ribbon and click on 'Solver' in the Analyze group.

4
Configure the Solver parameters

Set the 'Set Objective' box to your SUMPRODUCT cell (C2). Choose 'Value Of' and enter your target sum (e.g., 39). Set 'By Changing Variable Cells' to your column B range (B2:B20).

5
Add a binary constraint

Click 'Add' next to the 'Subject to the Constraints' box. Select your column B range (B2:B20) for the Cell Reference, choose 'bin' from the middle drop-down menu, and click OK.

6
Solve for the target

Click the 'Solve' button. Excel will alter the 0s to 1s for the numbers that match your target sum. Click OK to keep the solver solution.

Use the Excel Solver Add-in to Find a Single Combination
Solver Limitations: Solver will stop as soon as it finds the first valid combination. If there are multiple ways to reach your target sum, Solver will only display one of them.
Advanced Spreadsheet Capabilities

Easily Solve Complex Data Combinations in WPS Spreadsheet

WPS Spreadsheet features built-in advanced data analysis tools and robust VBA macro support, enabling you to effortlessly tackle target sum combinations and complex data scenarios without expensive software.

  1. 1. Download and install WPS Office: Get the free WPS Office suite from the official website and easily install it on your device.
  2. 2. Open your data list: Launch WPS Spreadsheet and open your existing Excel file containing the list of numbers.
  3. 3. Utilize Solver or VBA: Navigate to the Data tab to access the built-in optimization tools, or use the Developer tab to run your combination-finding macros.
Fully compatible with Microsoft Excel (.xlsx) formats and formulasIncludes a powerful built-in Solver tool for advanced data modelingSupports VBA macros for automating multiple combination searchesLightweight, lightning-fast, and completely free to use
microsoft office alternative - wps office

Frequently Asked Questions

Why can't I use Goal Seek to find number combinations?

Goal Seek is strictly designed to adjust only one variable cell to achieve a specific target result. Finding a combination of numbers requires evaluating and changing multiple variables (inclusion or exclusion of several numbers) simultaneously, making Solver or VBA necessary.

How do I enable the Solver Add-in if I don't see it on the Data tab?

Go to File > Options > Add-Ins. At the bottom of the window, ensure 'Excel Add-ins' is selected in the Manage drop-down and click 'Go'. Check the box next to 'Solver Add-in' and click OK. The Solver tool will now appear on the Data tab.

Will Solver find every possible combination that equals the target?

No, Solver is designed to find a single feasible solution. Once it identifies one combination of numbers that matches your target sum, it stops calculating. To view all possible combinations, you must use a VBA macro.

What happens if no combination equals my exact target?

If there is no mathematical combination of the provided numbers that perfectly matches your target sum, Solver will return a dialog box stating 'Solver could not find a feasible solution.' Ensure your target number and data list are correct.