Note: The other languages of the website are Google-translated. Back to English
Mewngofnodi  \/ 
x
or
x
Cofrestru  \/ 
x

or

Sut i restru neu gynhyrchu'r holl gyfuniadau posibl yn Excel?

Gadewch i ni ddweud, mae gen i'r ddwy golofn ganlynol o ddata, a nawr, rydw i eisiau cynhyrchu rhestr o'r holl gyfuniadau posib yn seiliedig ar y ddwy restr o werthoedd fel y dangosir y llun chwith. Efallai, gallwch chi restru'r holl gyfuniadau fesul un os nad oes llawer o werthoedd, ond, os oes angen rhestru sawl colofn â gwerthoedd lluosog y cyfuniadau posib, dyma rai triciau cyflym a allai eich helpu i ddelio â'r broblem hon yn Excel .

Rhestrwch neu cynhyrchwch yr holl gyfuniadau posib o ddwy restr gyda fformiwla

Rhestrwch neu cynhyrchwch yr holl gyfuniadau posibl o dair rhestr neu fwy gyda chod VBA

Rhestrwch neu cynhyrchwch yr holl gyfuniadau posibl o restrau lluosog gyda nodwedd bwerus


Rhestrwch neu cynhyrchwch yr holl gyfuniadau posib o ddwy restr gyda fformiwla

Gall y fformiwla hir ganlynol eich helpu i restru'r holl gyfuniadau posibl o werthoedd dwy restr yn gyflym, gwnewch fel a ganlyn:

1. Rhowch neu copïwch y fformiwla isod i mewn i gell wag, yn yr achos hwn, byddaf yn ei rhoi yng nghell D2, ac yna'n pwyso Rhowch allwedd i gael y canlyniad, gweler y screenshot:

=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))

Nodyn: Yn y fformiwla uchod, $ A $ 2: $ A $ 5 yw ystod gwerthoedd y golofn gyntaf, a $ B $ 2: $ B $ 4 yw ystod y gwerthoedd ail restr yr ydych am restru eu holl gyfuniadau posibl, y $ D $ 2 yw'r gell rydych chi'n rhoi'r fformiwla, gallwch chi newid cyfeiriadau'r gell i'ch angen.

2. Yna dewiswch gell D2 a llusgwch y handlen llenwi i lawr i'r celloedd nes cael y celloedd gwag, ac mae'r holl gyfuniadau posib wedi'u rhestru yn seiliedig ar werthoedd y ddwy restr. Gweler y screenshot:


Rhestrwch neu cynhyrchwch yr holl gyfuniadau posibl o dair rhestr neu fwy gyda chod VBA

Efallai bod y fformiwla uchod ychydig yn anodd i chi ei defnyddio, os oes data colofnau lluosog, bydd yn drafferthus i'w haddasu. Yma, byddaf yn cyflwyno cod VBA i ddelio ag ef yn gyflym.

1. Daliwch i lawr y ALT + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Cynhyrchu pob cyfuniad o 3 neu fwy o golofnau

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
Nodyn: Yn y cod uchod, A2: A5, B2: B4, C2: C4 yw'r ystod ddata rydych chi am ei defnyddio, E2 yw'r gell allbwn rydych chi am ddod o hyd i'r canlyniadau. Os ydych chi am gael pob cyfuniad o fwy o golofnau, newidiwch ac ychwanegwch baramedrau eraill i'r cod fel eich angen.

3. Yna, pwyswch F5 allwedd i redeg y cod hwn, a chynhyrchir pob cyfuniad o'r 3 colofn ar unwaith, gweler y screenshot:


Rhestrwch neu cynhyrchwch yr holl gyfuniadau posibl o restrau lluosog gyda nodwedd bwerus

Os oes rhestrau lluosog mae angen rhestru gwerthoedd y cyfuniadau posibl, efallai ei bod yn anodd ichi addasu'r cod. Yma, gallaf argymell teclyn pwerus - Kutools ar gyfer Excel, mae'n cynnwys nodwedd ddefnyddiol Rhestrwch Pob Cyfuniad a all restru'r holl gyfuniadau posibl yn gyflym yn seiliedig ar restrau data penodol.

Awgrymiadau:I gymhwyso hyn Rhestrwch Pob Cyfuniad nodwedd, yn gyntaf, dylech lawrlwytho'r Kutools ar gyfer Excel, ac yna cymhwyswch y nodwedd yn gyflym ac yn hawdd.

Ar ôl gosod Kutools ar gyfer Excel, gwnewch fel hyn:

1. Cliciwch Kutools > Mewnosod > Rhestrwch Pob Cyfuniad, gweler y screenshot:

2. Yn y Rhestrwch Pob Cyfuniad blwch deialog, gwnewch y gweithrediadau fel y dangosir isod:

3. Yna mae'r holl werthoedd a gwahanyddion penodedig wedi'u rhestru yn y blwch deialog, gweler y screenshot:

4Ac yna cliciwch Ok botwm, a bydd blwch prydlon yn popio allan i'ch atgoffa i ddewis cell i allbwn y canlyniad, gweler y screenshot:

5. Cliciwch OK, mae'r holl gyfuniadau posibl yn seiliedig ar y rhestrau a roddwyd wedi'u cynhyrchu i'r daflen waith fel y dangosir y llun a ganlyn:

Cliciwch i Lawrlwytho Kutools ar gyfer Excel Nawr!


Erthyglau mwy cymharol:

  • Cynhyrchu Pob Cyfuniad O 3 Colofn Lluosog
  • Gan dybio, mae gen i 3 colofn o ddata, nawr, rydw i eisiau cynhyrchu neu restru'r holl gyfuniadau o'r data yn y 3 colofn hyn fel y dangosir isod. A oes gennych unrhyw ddulliau da ar gyfer datrys y dasg hon yn Excel?
  • Dewch o Hyd i'r Holl Gyfuniadau sy'n Gyfwerth â Swm a Roddwyd
  • Er enghraifft, mae gen i'r rhestr ganlynol o rifau, ac yn awr, rydw i eisiau gwybod pa gyfuniad o rifau yn y rhestr sy'n cyfrif hyd at 480, yn y screenshot canlynol a ddangosir, gallwch chi weld bod yna bum grŵp o gyfuniadau posib sy'n adio yn gyfartal i 480, fel 300 + 60 + 120, 300 + 60 + 40 + 80, ac ati. Yr erthygl hon, byddaf yn siarad am rai dulliau i ddarganfod pa gelloedd sy'n dod i werth penodol yn Excel.
  • Cynhyrchu Neu Restru Pob Cyfresiad Posibl
  • Er enghraifft, mae gen i dri chymeriad XYZ, nawr, rydw i eisiau rhestru'r holl drawsnewidiadau posib yn seiliedig ar y tri chymeriad hyn i gael chwe chanlyniad gwahanol fel hyn: XYZ, XZY, YXZ, YZX, ZXY a ZYX. Yn Excel, sut allech chi gynhyrchu neu restru'r holl drawsnewidiadau yn gyflym yn seiliedig ar nifer wahanol o gymeriadau?
  • Cynhyrchu Rhestr o'r Holl Gyfuniadau Posibl 4 Digid
  • Mewn rhai achosion, efallai y bydd angen i ni gynhyrchu rhestr o'r holl gyfuniadau 4 digid posib o rif 0 i 9, sy'n golygu cynhyrchu rhestr o 0000, 0001, 0002… 9999. Er mwyn datrys y dasg rhestr yn Excel yn gyflym, rwy'n cyflwyno rhai triciau i chi.

Yr Offer Cynhyrchedd Swyddfa Gorau

Mae Kutools for Excel yn Datrys y rhan fwyaf o'ch Problemau, ac yn Cynyddu Eich Cynhyrchedd 80%

  • Ailddefnyddio: Mewnosod yn gyflym fformwlâu cymhleth, siartiau ac unrhyw beth rydych chi wedi'i ddefnyddio o'r blaen; Amgryptio Celloedd gyda chyfrinair; Creu Rhestr Bostio ac anfon e-byst ...
  • Bar Fformiwla Gwych (golygu llinellau lluosog o destun a fformiwla yn hawdd); Cynllun Darllen (darllen a golygu nifer fawr o gelloedd yn hawdd); Gludo i'r Ystod Hidlo...
  • Uno Celloedd / Rhesi / Colofnau heb golli Data; Cynnwys Celloedd Hollt; Cyfuno Rhesi / Colofnau Dyblyg... Atal Celloedd Dyblyg; Cymharwch y Meysydd...
  • Dewiswch Dyblyg neu Unigryw Rhesi; Dewiswch Blank Rows (mae pob cell yn wag); Darganfyddiad Gwych a Darganfyddiad Niwlog mewn Llawer o Lyfrau Gwaith; Dewis ar Hap ...
  • Copi Union Celloedd Lluosog heb newid cyfeirnod fformiwla; Auto Creu Cyfeiriadau i Daflenni Lluosog; Mewnosod Bwledi, Blychau Gwirio a mwy ...
  • Testun Detholiad, Ychwanegu Testun, Tynnu yn ôl Swydd, Tynnwch y Gofod; Creu ac Argraffu Subtotals Paging; Trosi rhwng Cynnwys a Sylwadau Celloedd...
  • Hidlo Super (arbed a chymhwyso cynlluniau hidlo i ddalenni eraill); Trefnu Uwch yn ôl mis / wythnos / dydd, amlder a mwy; Hidlo Arbennig gan feiddgar, italig ...
  • Cyfuno Llyfrau Gwaith a Thaflenni Gwaith; Uno Tablau yn seiliedig ar golofnau allweddol; Rhannwch Ddata yn Daflenni Lluosog; Trosi Swp xls, xlsx a PDF...
  • Mwy na 300 o nodweddion pwerus. Yn cefnogi Swyddfa / Excel 2007-2019 a 365. Yn cefnogi pob iaith. Defnydd hawdd yn eich menter neu sefydliad. Nodweddion llawn treial am ddim 30 diwrnod. Gwarant arian yn ôl 60 diwrnod.
tab kte 201905

Mae Tab Office yn Dod â rhyngwyneb Tabbed i'r Swyddfa, a Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
gwaelod officetab
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.