Thank you very much once again for your code, yesterday!
I tried to get each in their own sheet, instead of all on sheet 2, and used the following code, which is not really working....
If you would be kind enough to help me out once more?
Thank you.
Sub AddAsLastWorksheet_ProductSummary()
Application.ScreenUpdating = False
For Each c In Worksheets("Hidden_Calculations").Range("i11:i20000").Cells
If c <> "" Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = c.Value
Const TEST_COLUMN As String = "a" '<=== change to suit
Dim i As Long
Dim LastRow As Long
Dim NextRow As Long
Dim RowNum As Long
Dim sh As Worksheet
Set sh = Worksheets(Worksheets.Count)
With ActiveSheet
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = LastRow To 1 Step -1
NextRow = 0
On Error Resume Next
NextRow = Application.Match(.Cells(i, TEST_COLUMN).Value, sh.Columns(1), 0)
On Error GoTo 0
If NextRow = 0 Then
sh.Rows(1).Insert
sh.Range("A10").Value = .Cells(i, TEST_COLUMN).Value & " Total"
sh.Rows(1).Insert
sh.Range("A10").Value = .Cells(i, TEST_COLUMN).Value
NextRow = 2
Else
NextRow = NextRow + 1
End If
sh.Rows(NextRow).Insert
sh.Cells(NextRow, "A").Value = .Cells(i, "B").Value
sh.Cells(NextRow, "B").Value = .Cells(i, "D").Value
On Error Resume Next
RowNum = Application.Match(.Cells(i, TEST_COLUMN).Value & " Total", sh.Columns(1), 0)
On Error GoTo 0
sh.Cells(RowNum, "B").Value = sh.Cells(RowNum, "B").Value + .Cells(i, "C").Value
Next i
End With
End If
Next
End Sub