How to list or generate all possible combinations in Excel?

How to list or generate all possible combinations in Excel?

List or generate all possible combinations from two lists with formula

The following farseeing formula can help you to list all possible combinations of two lists values cursorily, please do as follows :
1. accede or copy the below recipe into a blank cell, in this font, I will enter it to cell D2, and then press Enter key to get the solution, see screenshot :


Note : In the above formula, $A$2:$A$5 is the range of the first column values, and $B$2:$B$4 is the range of the irregular number values which you want to list all their possible combinations, the $D$2 is the cell that you put the formula, you can change the cell references to your need .
2. then blue-ribbon cellular telephone D2 and drag the fill handle down to the cells until get the blank cells, and all the possible combinations have been listed based on the two lists values. See screenshot :

List or generate all possible combinations from three or more lists with VBA code

possibly the above formula is reasonably unmanageable for you to apply, if there are multiple columns data, it will be troublesome for modifying. here, I will introduce a VBA code to deal with it quickly .
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window .
2. Click Insert > Module, and paste the take after code in the Module Window .
VBA code: Generate all combinations of 3 or multiple columns

Sub ListAllCombinations()
'Updateby Extendoffice
Dim xDRg1, xDRg2, xDRg3 As Range
Dim xRg  As Range
Dim xStr As String
Dim xFN1, xFN2, xFN3 As Integer
Dim xSV1, xSV2, xSV3 As String
Set xDRg1 = Range("A2:A5")  'First column data
Set xDRg2 = Range("B2:B4")  'Second column data
Set xDRg3 = Range("C2:C4")  'Third column data
xStr = "-"   'Separator
Set xRg = Range("E2")  'Output cell
For xFN1 = 1 To xDRg1.Count
    xSV1 = xDRg1.Item(xFN1).Text
    For xFN2 = 1 To xDRg2.Count
        xSV2 = xDRg2.Item(xFN2).Text
      For xFN3 = 1 To xDRg3.Count
        xSV3 = xDRg3.Item(xFN3).Text
        xRg.Value = xSV1 & xStr & xSV2 & xStr & xSV3
        Set xRg = xRg.Offset(1, 0)
End Sub

Note : In the above code, A2:A5, B2:B4, C2:C4 are the data range that you want to use, E2 is the output cellular telephone that you want to locate the results. If you want to get all combinations of more columns, please change and add other parameters to the code as your indigence .
3. then, press F5 key to run this code, and all combinations of the 3 column will be generated at once, see screenshot :

List or generate all possible combinations from multiple lists with a powerful feature

If there are multiple lists values need to be listed the potential combinations, possibly it is difficult for you to modify the code. here, I can recommend a herculean cock — Kutools for Excel, it contains a handy feature of speech List All Combinations which can promptly list all the possible combinations based on given data lists .
Tips: List All Combinations feature, firstly, you should download the Kutools for Excel, and then apply the feature quickly and easily. To apply thisfeature, first, you should download the, and then apply the feature cursorily and easily . After installing Kutools for Excel, please do as this :
1. Click Kutools > Insert > List All Combinations, see screenshot :

2. In the List All Combinations dialogue box, do the operations as below show shown :

3. then all the specified values and separators have been listed into the dialogue box, see screenshot :

4 .And then chink Ok button, and a prompt box will pop out to remind you select a cell to end product the solution, see screenshot :

5. Click OK, all of the possible combinations based on the given lists have been generated into the worksheet as following screenshot shown :

Click to Download Kutools for Excel Now !

More relative articles:

  • Generate All Combinations Of 3 Or Multiple Columns
  • Supposing, I have 3 columns of data, now, I want to generate or list all combinations of the data in these 3 columns as below screenshot shown. Do you have any good methods for solving this task in Excel?
  • Find All Combinations That Equal A Given Sum
  • For example, I have the following list of numbers, and now, I want to know which combination of numbers in the list sum up to 480, in the following screenshot shown, you can see there are five groups of possible combinations that add up equal to 480, such as 300+60+120, 300+60+40+80, etc. This article, I will talk about some methods to find which cells sum up to a specific value in Excel.
  • Generate Or List All Possible Permutations
  • For example, I have three characters XYZ, now, I want to list all possible permutations based on these three characters to get six different results as this: XYZ, XZY, YXZ, YZX, ZXY and ZYX. In Excel, how could you quickly generate or list all permutations based on different number of characters?
  • Generate A List Of All Possible 4 Digits Combinations
  • In some cases, we may need to generate a list of all possible 4 digits combinations of number 0 to 9, which means to generate a list of 0000, 0001, 0002…9999. To quickly solve the list task in Excel, I introduce some tricks for you.

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by

  • Reuse : Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails…
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); paste to Filtered Range…
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns… Prevent Duplicate Cells; Compare Ranges…
  • choice Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select…
  • exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more…
  • Extract Text, Add Text, Remove by Position, Remove distance; Create and Print Paging Subtotals; Convert Between Cells Content and Comments…
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; extra Filter by bold, italic…
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF…
  • More than 300 potent features. Supports Office/Excel
    2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
    30-day free trial. 60-day money back guarantee.

kte tab 201905
Read More… Free Download… Purchase… 

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!

officetab bottom
Read More… Free Download… Purchase… 

source :
Category : Finance

Post navigation

Leave a Comment

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *