Hi,
See if this code can help you. It's using a Dictionary of Dictionaries.
It's not complete because it only compiles the February data but it should get you started. What it does is take the data for February and outputs it to a new sheet called Output.
By adding a loop you could go through each month in the "Data entry" sheet and compile the results.
Sub test()
Dim ar
Dim i As Long, j As Long
Dim DicC, DicP, e, s
Dim sMonth As String
Dim m As Integer, n As Long
Set DicC = CreateObject("Scripting.dictionary")
ar = Sheets("Data Entry").Range("A1").Cells(1).CurrentRegion.Value
sMonth = ar(1, 1)
For i = 3 To UBound(ar, 1)
If Not DicC.exists(ar(i, 1)) Then
Set DicC.Item(ar(i, 1)) = CreateObject("Scripting.dictionary")
For j = 4 To UBound(ar, 2) Step 2
If ar(i, j) <> "" Then
With DicC(ar(i, 1))
If Not DicC(ar(i, 1)).exists(ar(i, j)) Then
DicC.Item(ar(i, 1))(ar(i, j)) = ar(i, j - 1)
Else
DicC.Item(ar(i, 1))(ar(i, j)) = DicC.Item(ar(i, 1))(ar(i, j)) + ar(i, j - 1)
End If
End With
End If
Next j
End If
Next i
m = 1
With Sheets("Output")
.Range("A1") = sMonth
For Each e In DicC
If DicC(e).Count > 0 Then
.Cells(2, m) = e
.Cells(2, m + 1) = "Amount"
n = 3
For Each s In DicC(e)
.Cells(n, m) = s
.Cells(n, m + 1) = DicC(e)(s)
n = n + 1
Next s
m = m + 2
End If
Next e
End With
End Sub
Bookmarks