Pivot tables are frustrating me again. I use the underlying code to refresh a pivot table, but if a new item has been added to the table, that item is indented twice as far as the others. In a "normal" cell it would be an indentation of 2, but I need it to be 1. I can't seem to find anything on the web that says how to adjust indentation in a pivot table. I took a stab at it, and have included that below as well.
VBA Code:
'This is what I'm using to refrsh the pivot table.
'mS.PivotTables("InitSummary").ChangePivotCache ActiveWorkbook.PivotCaches.Create(xlDatabase, SourceData:=m.Sheets("Inventory").Range("A2:AE" & mILR))
VBA Code:
Sub Macro1()
Dim m As Workbook
Dim mS As Worksheet
Dim PT As PivotTable
Dim PF As PivotField
Dim c As Range
Set m = ThisWorkbook
Set mS = m.Sheets("Summaries")
Set PT = mS.PivotTables("InitSummary")
For Each c In PT.RowFields("Title") ''I'm getting the "Object doesn't support this property or method" error.
If c.IndentLevel = 2 Then
c.IndentLevel = 1
Else: Exit Sub
End If
Next c
'This is what I'm using to refrsh the pivot table.
'mS.PivotTables("InitSummary").ChangePivotCache ActiveWorkbook.PivotCaches.Create(xlDatabase, SourceData:=m.Sheets("Inventory").Range("A2:AE" & mILR))
End Sub