A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
To make it more flexible I added a variable that you can change, though I hope your table only goes through Y5, which is 24 columns of pallet prices.
Sub TestMacro24()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim lRow As Long
Dim iTotal As Integer
Dim iSize As Integer
iSize = 24 'Set Size Here
lRow = 8
Cells(lRow, 1).Value = "A1"
Cells(lRow, 2).Value = "B1"
Cells(lRow, 3).Value = "C1"
Cells(lRow, 4).Value = "D1"
Cells(lRow, 5).Value = "Total"
For i = 0 To iSize
For j = 0 To iSize - i
For k = 0 To iSize - i - j
l = iSize - i - j - k
lRow = lRow + 1
iTotal = IIf(l <> 0, Cells(2, l + 1).Value, 0) + _
IIf(k <> 0, Cells(3, k + 1).Value, 0) + _
IIf(j <> 0, Cells(4, j + 1).Value, 0) + _
IIf(i <> 0, Cells(5, i + 1).Value, 0)
Cells(lRow, 1).Value = l
Cells(lRow, 2).Value = k
Cells(lRow, 3).Value = j
Cells(lRow, 4).Value = i
Cells(lRow, 5).Value = iTotal
Next k
Next j
Next i
End Sub