Function PermutationCombination(data1 As Range, data2 As Range, data3 As Range) As Variant
    ' data1,data2,data3 分别为三组数据的单元格范围,如 A1:A5
    ' 返回三组数据的所有排列组合
    Dim output() As Variant
    ReDim output(1 To data1.Cells.Count * data2.Cells.Count * data3.Cells.Count, 1 To 3)
    Dim i As Long, j As Long, k As Long
    Dim idx As Long
    For i = 1 To data1.Cells.Count
        For j = 1 To data2.Cells.Count
            For k = 1 To data3.Cells.Count
                idx = idx + 1
                output(idx, 1) = data1.Cells(i, 1).Value
                output(idx, 2) = data2.Cells(j, 1).Value
                output(idx, 3) = data3.Cells(k, 1).Value
            Next k
        Next j
    Next i
    PermutationCombination = output
End Function