Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to find all possible sums of two numbers in a list in Excel?

Author Sun Last modified

If you need to find all possible sums of two numbers in a list or list all possible combinations of two lists in Excel, there are no built-in functions to achieve this directly. This guide introduces a VBA code solution for calculating sums and the List All Combinations utility in Kutools for Excel for handling combinations efficiently.
A screenshot showing a list of numbers for calculating all possible sums in Excel

Find all possible sums of two numbers in a list with VBA code

Find all possible combinations of two lists with List All Combinationsgood idea3


Find all possible sums of two numbers in a list with VBA code

If you want to find all possible sums of two numbers in a list, you can apply below VBA code.

1. Press Alt + F11 keys to display the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, copy and paste below code to the module.

VBA: List all possible sums of two numbers in a list

Sub Combinations()
'UpdatebyExtendoffice20180628
    Dim xRgArr
    Dim xNum As Long
    Dim I, J, K As Long
    Dim xTemp As Double
    Dim xRg As Range
    Dim xRgCount As Long
    Dim xDic As New Dictionary
    On Error Resume Next
    Set xRg = Application.InputBox("Select a list (one column):", "KuTools for Excel", Selection.Address, , , , , 8)
    If (xRg Is Nothing) Or (xRg.Count = 1) Then Exit Sub
    xRgCount = xRg.Count
    K = 1
    ReDim xRgArr(1 To xRgCount)
    For Each xCell In xRg
      xRgArr(K) = xCell.Value
      K = K + 1
    Next
    K = 0
    For I = 1 To xRgCount
        For J = I + 1 To xRgCount
            xTemp = xRgArr(I) + xRgArr(J)
            If Not xDic.Exists(xTemp) Then
                xDic.Add CDbl(xTemp), CStr(xTemp)
                K = K + 1
            End If
        Next
    Next
    Range("C1").Resize(xDic.Count, 1) = Application.WorksheetFunction.Transpose(xDic.Keys)
End Sub

A screenshot of the VBA editor showing code for listing all possible sums of two numbers in Excel

3. Click Tools > References, in the popping dialog, check Microsoft Scripting Runtime checkbox.

A screenshot showing the References option in the VBA window Arrow right A screenshot showing the References dialog in Excel VBA for enabling the Microsoft Scripting Runtime library

4. Click OK to close the dialog, then press F5 to run the code. A dialog will appear, prompting you to select a list for calculating the possible sums.
A screenshot showing the dialog to select a list for calculating all possible sums

5. Click OK, then all possible sums of two numbers from the list will be displayed in column C.
A screenshot showing all possible sums of two numbers listed in column C

Tip: In the code string Range("C1").Resize(xDic.Count, 1), you can change C1 to any other cell where you want to place the results.


Find all possible combinations of two lists with List All Combinations

If you want to list all possible combinations of two lists, as shown in the screenshot below, the List All Combinations utility of Kutools for Excel can do you a favor.
A screenshot showing two lists of values for creating all possible combinations in Excel

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

1. Click Kutools > Insert > List All Combinations.
A screenshot showing the List All Combinations tool in Kutools tab in Excel

2. In the List All Combinations dialog, click the select button to select the first list you will combine.
A screenshot showing the selection of the first list in the List All Combinations tool

3. Click Add to add the list into Combinations list section.
A screenshot showing how to add the first list to the combinations list in Kutools

4. Repeat step 2 and 3 to add the second list to the Combinations list.
A screenshot showing how to add the second list to the combinations list in Kutools

5. Then click Ok to select a cell to place the combination result.
A screenshot showing the cell selection dialog for placing combinations

6. Click OK. All possible combinations have been listed in cells.
A screenshot showing all possible combinations of two lists created in Excel using Kutools

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now

Demo: Find all possible combinations of two lists with Kutools for Excel

Kutools for Excel: Over 300 handy tools at your fingertips! Enjoy permanently free AI features! Download Now!

Best Office Productivity Tools

šŸ¤– Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in