Trying to create all unique combinations of values for each row given the fact that each each cell may or may not have multiple nested values. The goal is to interpret each row and write a new line for each unique combination of the values.
Sub combo(x As Integer, splitCell As Boolean, lastcol As Long)
Dim cellArray() As String
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Test")
For y = lastcol To 2 Step -1
Dim counter As Integer
counter = 0
cellValue = ws.Cells(x, y).Value
cellArray() = Split(cellValue, Chr(10))
Debug.Print cellValue
If UBound(cellArray()) > LBound(cellArray()) Then
Debug.Print "Splitting " & x, y
For t = UBound(cellArray()) To LBound(cellArray()) Step -1
Rows(x + counter).Offset(1).EntireRow.Insert
counter = counter + 1
For a = lastcol To 1 Step -1
If a = y Then
ws.Cells(x + counter, a).Value = cellArray(t)
splitCell = True
rowToDel = x
Else
ws.Cells(x + counter, a).Value = ws.Cells(x, a).Value
splitCell = True
End If
Next a
Next t
End If
x = x + counter
Next y
If splitCell = True Then
Rows(rowToDel).EntireRow.Delete
End If
x = x - 1
lastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
End Sub
This code currently works for the case of having one cell with nested values versus single entries in other cells in that row. However, there are cases of up to three columns each with nested values that unique entries should be made for.