Another approach
Rearange the data in your file, with this macro.
After that you will be able to add the subcat. at once.
See the attached file.
I did not update the pivot table (make a new pivot table).
Dim rsht1 As Long, rsht2 As Long, i As Long, Col As Long, wsTest As Worksheet
'check if sheet "ouput" already exist
Const strSheetName As String = "Output"
Set wsTest = Nothing
On Error Resume Next
Set wsTest = ActiveWorkbook.Worksheets(strSheetName)
On Error GoTo 0
If wsTest Is Nothing Then
Worksheets.Add.Name = strSheetName
End If
With Sheets("Output")
.UsedRange.ClearContents
.Range("A1:E1").Value = Array("scrubbed", "date", "category", "Sub", "Value")
End With
rsht1 = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Row
rsht2 = Sheets("Output").Range("A" & Rows.Count).End(xlUp).Row
Col = 4
For i = 2 To rsht1
Do While Sheets("sheet1").Cells(1, Col).Value <> ""
rsht2 = rsht2 + 1
Sheets("Output").Range("A" & rsht2).Value = Sheets("sheet1").Range("A" & i).Value
Sheets("Output").Range("B" & rsht2).Value = Sheets("sheet1").Range("B" & i).Value
Sheets("Output").Range("C" & rsht2).Value = Sheets("sheet1").Range("C" & i).Value
Sheets("Output").Range("D" & rsht2).Value = Sheets("sheet1").Cells(1, Col).Value
Sheets("Output").Range("E" & rsht2).Value = Sheets("sheet1").Cells(i, Col).Value
Col = Col + 1
Loop
Col = 4
Next
With Sheets("Output")
' .Range("E2:E" & .Rows.Count).SpecialCells(4).EntireRow.Delete
Columns("A:Z").EntireColumn.AutoFit
End With
Bookmarks