Note: The other languages of the website are Google-translated. Back to English
Vpiši se  \/ 
x
or
x
Registracija  \/ 
x

or

Kako našteti ali ustvariti vse možne kombinacije v Excelu?

Recimo, da imam naslednja dva stolpca podatkov, zdaj pa želim ustvariti seznam vseh možnih kombinacij na podlagi obeh seznamov vrednosti, kot je prikazano na levi sliki zaslona. Mogoče lahko naštejete vse kombinacije eno za drugo, če je vrednosti malo, če pa je za naštevanje možnih kombinacij več stolpcev z več vrednostmi, je tukaj nekaj hitrih trikov, ki vam lahko pomagajo pri reševanju te težave v Excelu. .

Navedite ali ustvarite vse možne kombinacije iz dveh seznamov s formulo

Navedite ali ustvarite vse možne kombinacije s treh ali več seznamov s kodo VBA

Seznam ali generiranje vseh možnih kombinacij iz več seznamov z zmogljivo funkcijo


Navedite ali ustvarite vse možne kombinacije iz dveh seznamov s formulo

Naslednja dolga formula vam lahko pomaga hitro našteti vse možne kombinacije vrednosti dveh seznamov. Naredite naslednje:

1. Vnesite ali kopirajte spodnjo formulo v prazno celico, v tem primeru jo vnesem v celico D2 in nato pritisnem Vnesite tipko, da dobite rezultat, glejte sliko zaslona:

=IF(ROW()-ROW($D$2)+1>COUNTA($A$2:$A$5)*COUNTA($B$2:$B$4),"",INDEX($A$2:$A$5,INT((ROW()-ROW($D$2))/COUNTA($B$2:$B$4)+1))&"-"&INDEX($B$2:$B$4,MOD(ROW()-ROW($D$2),COUNTA($B$2:$B$4))+1))

Opombe: V zgornji formuli, 2 A $ 5: XNUMX A $ je obseg vrednosti prvih stolpcev in $ 2 $: $ 4 $ je obseg vrednosti drugega seznama, za katere želite navesti vse njihove možne kombinacije, $ D $ 2 je celica, v katero ste postavili formulo, lahko sklice na celice spremenite glede na vaše potrebe.

2. Nato izberite celico D2 in povlecite ročico za polnjenje navzdol do celic, dokler ne dobite praznih celic, na podlagi vrednosti dveh seznamov pa so bile navedene vse možne kombinacije. Oglejte si posnetek zaslona:


Navedite ali ustvarite vse možne kombinacije s treh ali več seznamov s kodo VBA

Mogoče je zgornjo formulo nekoliko težko uporabiti, če je podatkov o stolpcih več, bo to težavno za spreminjanje. Tukaj bom predstavil kodo VBA za hitro obravnavo.

1. Držite tipko ALT + F11 tipke za odpiranje Microsoft Visual Basic za aplikacije okno.

2. Kliknite Vstavi > Moduliin prilepite naslednjo kodo v Moduli Okno.

Koda VBA: ustvari vse kombinacije 3 ali več stolpcev

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)
       Next
    Next
Next
End Sub
Opombe: V zgornji kodi, A2: A5, B2: B4, C2: C4 so obseg podatkov, ki ga želite uporabiti, E2 je izhodna celica, v kateri želite poiskati rezultate. Če želite dobiti vse kombinacije več stolpcev, spremenite in dodajte druge parametre v kodo, kot želite.

3. Nato pritisnite F5 za zagon te kode in vse kombinacije treh stolpcev bodo ustvarjene hkrati, glejte posnetek zaslona:


Seznam ali generiranje vseh možnih kombinacij iz več seznamov z zmogljivo funkcijo

Če je na seznamih več vrednosti, je treba navesti možne kombinacije, morda boste težko spremenili kodo. Tu lahko priporočim močno orodje - Kutools za Excel, vsebuje priročno funkcijo Seznam vseh kombinacij ki lahko na podlagi danih seznamov podatkov hitro našteje vse možne kombinacije.

nasveti:Če želite uporabiti to Seznam vseh kombinacij funkcijo, najprej morate prenesti Kutools za Excelin nato funkcijo hitro in enostavno uporabite.

Po namestitvi Kutools za Excel, naredite tako:

1. klik Kutools > Vstavi > Seznam vseh kombinacij, glej posnetek zaslona:

2. v Seznam vseh kombinacij v pogovornem oknu izvedite postopke, kot je prikazano spodaj:

3. Nato so bile vse navedene vrednosti in ločila navedena v pogovornem oknu, glejte posnetek zaslona:

4. In nato kliknite Ok in izpiše se pozivno polje, ki vas opomni, da izberete celico za izpis rezultata, glejte posnetek zaslona:

5. Kliknite OK, so vse možne kombinacije na podlagi danih seznamov ustvarjene v delovnem listu, kot je prikazano na sliki spodaj:

Kliknite za prenos Kutools za Excel zdaj!


Več relativnih člankov:

  • Ustvari vse kombinacije 3 ali več stolpcev
  • Recimo, da imam 3 stolpce podatkov, zdaj želim ustvariti ali navesti vse kombinacije podatkov v teh 3 stolpcih, kot je prikazano spodaj. Ali imate kakšne dobre metode za reševanje te naloge v Excelu?
  • Poiščite vse kombinacije, ki so enake dani vsoti
  • Na primer, imam naslednji seznam številk, zdaj pa želim vedeti, katera kombinacija številk na seznamu znaša do 480, na naslednjem prikazanem posnetku zaslona lahko vidite, da obstaja pet skupin možnih kombinacij, ki se seštevajo enako do 480, na primer 300 + 60 + 120, 300 + 60 + 40 + 80 itd. V tem članku bom govoril o nekaterih metodah iskanja, katere celice seštejejo do določene vrednosti v Excelu.
  • Ustvari ali naštej vse možne permutacije
  • Na primer, imam tri znake XYZ, zdaj želim našteti vse možne permutacije, ki temeljijo na teh treh znakih, da dobim šest različnih rezultatov: XYZ, XZY, YXZ, YZX, ZXY in ZYX. Kako lahko v Excelu hitro ustvarite ali navedete vse permutacije glede na različno število znakov?
  • Ustvari seznam vseh mogočih 4-mestnih kombinacij
  • V nekaterih primerih bomo morda morali ustvariti seznam vseh možnih 4-mestnih kombinacij števil od 0 do 9, kar pomeni, da bomo ustvarili seznam 0000, 0001, 0002… 9999. Za hitro reševanje naloge s seznamom v Excelu vam predstavljam nekaj trikov.

Najboljša orodja za pisarniško produktivnost

Kutools za Excel rešuje večino vaših težav in poveča produktivnost za 80%

  • Ponovna uporaba: Hitro vstavite zapletene formule, grafikoni in vse, kar ste že uporabljali; Šifriraj celice z geslom; Ustvari poštni seznam in pošiljanje e-pošte ...
  • Vrstica Super Formula (enostavno urejanje več vrstic besedila in formule); Bralna postavitev (enostavno branje in urejanje velikega števila celic); Prilepite v filtrirani obseg...
  • Združi celice / vrstice / stolpce brez izgube podatkov; Vsebina razdeljenih celic; Združi podvojene vrstice / stolpce... prepreči podvojene celice; Primerjaj obsege...
  • Izberite Duplicate ali Unique Vrstice; Izberite prazne vrstice (vse celice so prazne); Super Find in Fuzzy Find v mnogih delovnih zvezkih; Naključna izbira ...
  • Natančna kopija Več celic brez spreminjanja sklica formule; Samodejno ustvarjanje referenc na več listov; Vstavi oznake, Potrditvena polja in še več ...
  • Izvleček besedila, Dodaj besedilo, Odstrani po položaju, Odstrani presledek; Ustvari in natisni vmesne seštevke strani Pretvarjanje med vsebino celic in komentarji...
  • Super filter (shranite in uporabite sheme filtrov za druge liste); Napredno razvrščanje glede na mesec / teden / dan, pogostost in drugo; Poseben filter s krepko, ležeče ...
  • Združite delovne zvezke in delovne liste; Spoji tabele na podlagi ključnih stolpcev; Razdelite podatke na več listov; Paketna pretvorba xls, xlsx in PDF...
  • Več kot 300 zmogljivih funkcij. Podpira Office / Excel 2007-2019 in 365. Podpira vse jezike. Preprosta namestitev v vašem podjetju ali organizaciji. Vse funkcije 30-dnevnega brezplačnega preskusa. 60-dnevno jamstvo za vračilo denarja.
zavihek kte 201905

Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50% in vsak dan zmanjša na stotine klikov z miško!
dno pisarniške mize
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Juan Tomás · 1 years ago
    Excelentes soluciones, muchas gracias, lo logré con Kutools
  • To post as a guest, your comment is unpublished.
    RAFFAELE · 1 years ago
    NON FUNZIONA. HO SEGUITO GLI STESSI PASSAGGI MA MI DICE CHE C'E' UN ERRORE
  • To post as a guest, your comment is unpublished.
    Guy · 1 years ago
    Is there a way to output this as a txt file? When you have millions of results in the D column it's not exactly practical to drag the fill handle.
  • To post as a guest, your comment is unpublished.
    JJ · 2 years ago
    Almost very handy. Would be good if it actually used whatever is in the cell ($A$1)and not convert the cell to text. Then I could just paste what I need in A1 and run it again without having to change anything.
  • To post as a guest, your comment is unpublished.
    pocholoclub@gmail.com · 2 years ago
    I used the extions and works fantastic,, but now i have a problem, i need to calculate the sum,, but the result is a text,, i enter a separator that is the simbol +, but finally i have a text and is impossible to convert in a operation.
  • To post as a guest, your comment is unpublished.
    sergio · 2 years ago
    Hello, and if these combinations intead text are number,, how can i made the calculation for the results???? i try to add the "+" but excel dont know that is the simbol.. how you solve this?
  • To post as a guest, your comment is unpublished.
    ricardo · 2 years ago
    Hola me arroja una referencia circula la formula
    =SI(FILA()-FILA($D$1)+1>(CONTARA($A$1:$A$4)*CONTARA($B$1:$B$3));"";INDICE($A$1:$A$4;RESIDUO((FILA()-FILA($D$1));COUNTA($B$1:$B$3)+1))
    &INDICE($B$1:$B$3;RESIDUO(FILA()-FILA($D$1);CONTARA($B$1:$B$3))+1))
  • To post as a guest, your comment is unpublished.
    anirbank · 3 years ago
    Why my formula did not work to create 25 combinations in Column E (5 elements from Col A * 5 elements from Col B) ? Whereas the formula in this article worked in Column D when I dragged it for 25 cells? Screenshot - https://prnt.sc/ihwr18
  • To post as a guest, your comment is unpublished.
    Mihai · 3 years ago
    Hi,
    I want to know what to do if I want to generate more than 1,4 million combination and I exceede the Excel rows limit?
    Is there a way of puting Kudos to continue its iteration on the next column?
  • To post as a guest, your comment is unpublished.
    Marco · 3 years ago
    Has anyone figured out a formula yet to do this for 5 sets of data? I've been stumped on this so far.
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, Marco,
      The Kutools can help you to solve your problem quickly,please check the following screenshot:
      Please try it, hope it can help you, thank you!
  • To post as a guest, your comment is unpublished.
    acomuna · 3 years ago
    Is KuTools able to sort cells in a row in a "simple combination" fashion?
    I mean, if I have these data:
    _________________________
    John Jack Paul Macy

    Mark Larry

    Jerry Paul Mary

    Sam Jeff Peter Lucas
    _________________________



    And I want to output them like this:
    ___________
    John Jack

    John Paul

    John Macy

    Jack Paul

    Jack Macy

    Paul Macy

    Mark Larry

    Jerry Paul

    Jerry Marry

    Paul Mary

    Sam Jeff

    Sam Peter

    Sam Lucas

    Jeff Peter

    Jeff Lucas

    Peter Lucas
    ____________


    How can I do this? Can KuTools do sth like this?

    Thanks!
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hi, Arthur,
      Sorry, the Kutools can not help you to solve this job as you said.
      Thank your for your comment.
  • To post as a guest, your comment is unpublished.
    Eoin · 3 years ago
    Any idea how to add a space inbetween ?
    • To post as a guest, your comment is unpublished.
      Mary · 3 years ago
      You can add a space by adding " "& before you index column B, right after the existing &, like so.....

      =IF(ROW()-ROW($D$1)+1>COUNTA($A$1:$A$4)*COUNTA($B$1:$B$3),"",INDEX($A$1:$A$4,INT((ROW()-ROW($D$1))/COUNTA($B$1:$B$3)+1))&" "&INDEX($B$1:$B$3,MOD(ROW()-ROW($D$1),COUNTA($B$1:$B$3))+1))


      ....or any other delimiter you like!
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, Eoin,
      the formula in this article can not help you to add a space between the cell values, but, you can apply the Kutools for Excel, with it, you can type any delimiter as you want to separate the combined result, see screenshot:
  • To post as a guest, your comment is unpublished.
    JiffyLimbo · 3 years ago
    For more columns:
    The first part of the formulate needs to be modified to multiply all the possibilities, for example this would be for 6 columns:

    COUNTA($A$2:$A$9)*COUNTA($B$2:$B$9)*COUNTA($C$2:$C$9)*COUNTA($D$2:$D$9)*COUNTA($E$2:$E$9)*COUNTA($F$2:$F$9)
    so you are adding
    *COUNTA(YourRangeHere)
    for each column

    The second part of the formula needs to be modified for each column as well like so:

    INDEX($A$2:$A$9,MOD(ROW()-ROW($I$2),COUNTA($A$2:$A$9))+1)&INDEX($B$2:$B$9,MOD(ROW()-ROW($I$2),COUNTA($B$2:$B$9))+1)&INDEX($C$2:$C$9,MOD(ROW()-ROW($I$2),COUNTA($C$2:$C$9))+1)&INDEX($D$2:$D$9,MOD(ROW()-ROW($I$2),COUNTA($D$2:$D$9))+1)&INDEX($E$2:$E$9,MOD(ROW()-ROW($I$2),COUNTA($E$2:$E$9))+1)&INDEX($F$2:$F$9,MOD(ROW()-ROW($I$2),COUNTA($F$2:$F$9))+1)

    so you are adding

    &INDEX(YourRangeHere,MOD(ROW()-ROW($I$2),COUNTA(YourRangeHere))+1)

    So put them all together and you get this example for 6 columns:

    =IF(ROW()-ROW($I$2)+1>COUNTA($A$2:$A$9)*COUNTA($B$2:$B$9)*COUNTA($C$2:$C$9)*COUNTA($D$2:$D$9)*COUNTA($E$2:$E$9)*COUNTA($F$2:$F$9),"",INDEX($A$2:$A$9,MOD(ROW()-ROW($I$2),COUNTA($A$2:$A$9))+1)&INDEX($B$2:$B$9,MOD(ROW()-ROW($I$2),COUNTA($B$2:$B$9))+1)&INDEX($C$2:$C$9,MOD(ROW()-ROW($I$2),COUNTA($C$2:$C$9))+1)&INDEX($D$2:$D$9,MOD(ROW()-ROW($I$2),COUNTA($D$2:$D$9))+1)&INDEX($E$2:$E$9,MOD(ROW()-ROW($I$2),COUNTA($E$2:$E$9))+1)&INDEX($F$2:$F$9,MOD(ROW()-ROW($I$2),COUNTA($F$2:$F$9))+1))

    Where you would paste this formula into $I$2 and it would be looking at $A$2:$A$9 $B$2:$B$9 $C$2:$C$9 ... up to $F$2:$F$9
    • To post as a guest, your comment is unpublished.
      JiffyLimbo · 3 years ago
      this doesn't work :( more complicated than this
  • To post as a guest, your comment is unpublished.
    JiffyLimbo · 3 years ago
    For more columns:
    The first part of the formulate needs to be modified to multiply all the possibilities, for example this would be for 6 columns
    COUNTA($A$2:$A$9)*COUNTA($B$2:$B$9)*COUNTA($C$2:$C$9)*COUNTA($D$2:$D$9)*COUNTA($E$2:$E$9)*COUNTA($F$2:$F$9)
    so you are adding
    *COUNTA(YourRangeHere)
    for each column
    The second part of the formula needs to be modified for each column as well like so:
    INDEX($A$2:$A$9,MOD(ROW()-ROW($I$2),COUNTA($A$2:$A$9))+1)&INDEX($B$2:$B$9,MOD(ROW()-ROW($I$2),COUNTA($B$2:$B$9))+1)&INDEX($C$2:$C$9,MOD(ROW()-ROW($I$2),COUNTA($C$2:$C$9))+1)&INDEX($D$2:$D$9,MOD(ROW()-ROW($I$2),COUNTA($D$2:$D$9))+1)&INDEX($E$2:$E$9,MOD(ROW()-ROW($I$2),COUNTA($E$2:$E$9))+1)&INDEX($F$2:$F$9,MOD(ROW()-ROW($I$2),COUNTA($F$2:$F$9))+1)
    so you are adding
    &INDEX(YourRangeHere,MOD(ROW()-ROW($I$2),COUNTA(YourRangeHere))+1)

    So put them all together and you get this example for 6 columns:

    =IF(ROW()-ROW($I$2)+1>COUNTA($A$2:$A$9)*COUNTA($B$2:$B$9)*COUNTA($C$2:$C$9)*COUNTA($D$2:$D$9)*COUNTA($E$2:$E$9)*COUNTA($F$2:$F$9),"",INDEX($A$2:$A$9,MOD(ROW()-ROW($I$2),COUNTA($A$2:$A$9))+1)&INDEX($B$2:$B$9,MOD(ROW()-ROW($I$2),COUNTA($B$2:$B$9))+1)&INDEX($C$2:$C$9,MOD(ROW()-ROW($I$2),COUNTA($C$2:$C$9))+1)&INDEX($D$2:$D$9,MOD(ROW()-ROW($I$2),COUNTA($D$2:$D$9))+1)&INDEX($E$2:$E$9,MOD(ROW()-ROW($I$2),COUNTA($E$2:$E$9))+1)&INDEX($F$2:$F$9,MOD(ROW()-ROW($I$2),COUNTA($F$2:$F$9))+1))

    Where you would paste this formula into $I$2 and it would be looking at $A$2:$A$9 $B$2:$B$9 $C$2:$C$9 ... up to $F$2:$F$9
    • To post as a guest, your comment is unpublished.
      JiffyLimbo · 3 years ago
      this doesnt work :( more complicated than this
  • To post as a guest, your comment is unpublished.
    Javier · 4 years ago
    anyone know how to modify this to reflect 6 columns of data?
  • To post as a guest, your comment is unpublished.
    Javier · 4 years ago
    anyone know how to modify this to reflect 6 columns of data, rather than just two?
    • To post as a guest, your comment is unpublished.
      shey · 3 years ago
      looking for the same thing. anyone know?
  • To post as a guest, your comment is unpublished.
    NB · 4 years ago
    How could you use KuTools, or even a formula, if you wanted all the permutations of the Month header. Jan, Jan and Feb, Jan and Mar, Jan and Mar, Jan and Feb and Mar, etc etc
  • To post as a guest, your comment is unpublished.
    jitu · 4 years ago
    VERY HELPFUL.I am now able to generate combinations very easily.
  • To post as a guest, your comment is unpublished.
    Veerendra Kumar · 4 years ago
    Can I get the formula for all the combinations of a 5*5 matrix (5 rows and 5 columns ) I tried but not able to get please help me.......
  • To post as a guest, your comment is unpublished.
    Free · 4 years ago
    Is there a way to make this formula work where it produces the various combinations still separated in 2 separate columns, but adjacent to one another?
    • To post as a guest, your comment is unpublished.
      Bill · 4 years ago
      Have you had any luck with this yet? I'm trying to do the same thing and have all of the possible combinations next to each other in a 2 separate columns.
    • To post as a guest, your comment is unpublished.
      Bill · 4 years ago
      Have you had any luck figuring out how to do this? I'm trying to do the exact same thing and have all of my probabilities in 2 separate columns in excel.
  • To post as a guest, your comment is unpublished.
    GATES · 4 years ago
    example : my list of values is 1,2,3,4,5,6......80 , i want kutool to display all combinations of a set of 2 numbers, example : 1-2 , 1-3 , 1-4 , 1-5 , ..................79-80 . is this possible with KUTOOL ?
  • To post as a guest, your comment is unpublished.
    Kyle · 5 years ago
    This is a brilliant formula! I have no clue how it works, but I just change the collum A and B to match how long my lists are, and have my output in D1.