I hope this is the right place to post this.
I'd like to combine all possible combinations (text) from a single column into another in a macro.
Lets say I've got 6 fruits (Apple, Orange, Grapefruit, Banana, Kiwi, Grapes) in column 1 (A1-A6). I'd like libreoffice to automatically combine all the possible combinations into column B. The data would then look like Apple orange, Apple grapefruit, apple banana etc etc.
I only need the pairs which are in alphabetical order, which means Banana, Orange but not, Orange, Banana.
I don't need duplicate pairs, like Apple, Apple.
I would like if it was possible to also create a macro where it's Triple combined like: Apple, Banana, Orange.
I have a macro who can do this for Excel but I would really like one for LibreOffice as well since my Office subscription expires soon.
This is the Macro for uniquepairs for Excel:
Code: Select all
Public Sub GetUniquePairs()
Dim lastRow As Long
Dim thisRow As Long
Dim i As Long
Dim j As Long
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
thisRow = 1
For i = 1 To lastRow - 1
For j = i + 1 To lastRow
Cells(thisRow, 3).Value = Cells(i, 1).Value & "," & Cells(j, 1).Value
thisRow = thisRow + 1
Next j
Next i
End Sub