Excel排列不重复从多列中的值

我在Excel文件中有什么:

AB Abc 12:34 Def 56:78 Ghi 90:12 Jkl 34:56 ... 

我想用这些价值来实现:

 CDEF Abc 12:34 Def 56:78 Abc 12:34 Ghi 90:12 Abc 12:34 Jkl 34:56 Def 56:78 Ghi 90:12 Def 56:78 Jkl 34:56 Ghi 90:12 Jkl 34:56 ... 

说明:

A列和B列可以包含文本和数字的任意组合(如果这很重要的话),这个例子只显示最常见的结构。 它应该创build仅用于“在途中”的行的组合,即“Abc … Def …”就足够了,不应该有“Def … Abc …”。

有很多例子,但我很努力地find一个这样的VBA版本与多列工作,不重复组合。

这是一个简单的例子。 但是,只有一列,它也重复了值:

http://www.mrexcel.com/forum/excel-questions/412952-create-list-all-pair-combinations.html#post2046893

先谢谢你。

鉴于我们在谈话中讨论的内容,下面是VBA中的一个解决scheme:

 Sub CreatePermutation() Dim FirstCell As Integer Dim SecondCell As Integer Dim NumRows As Integer Dim OutputRow As Long ' Get the total number of rows in column A NumRows = Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row() ' You want to start outputting in row 1 OutputRow = 1 For FirstCell = 1 To NumRows - 1 For SecondCell = FirstCell + 1 To NumRows ' Put in the data from the first cell into columnc C & D Cells(OutputRow, 3).Value = Cells(FirstCell, 1).Value Cells(OutputRow, 4).Value = Cells(FirstCell, 2).Value ' Put in the data from the second cell into column E & F Cells(OutputRow, 5).Value = Cells(SecondCell, 1).Value Cells(OutputRow, 6).Value = Cells(SecondCell, 2).Value ' Move to the next row to output OutputRow = OutputRow + 1 Next SecondCell Next FirstCell End Sub 

希望这能完成你想要做的事情。