David Evans
Active Member
Has anyone used VBA to loop through successive values in the report filter field? If so, any insight would be appreciated.
				
			Thanks Luke - I like that one also.Not a direct answer, but here's my go-to reference for when I need to deal with ranges in a PT. Hope it helps.
http://peltiertech.com/referencing-pivot-table-ranges-in-vba/
Sub Pivot_Loop()
  Dim pt As PivotTable
  Dim pi As PivotItem
  Set pt = ActiveSheet.PivotTables("ClientAccounts")
  For Each pi In pt.PageFields("Client ID").PivotItems
      pt.PageFields("Client ID").CurrentPage = pi.Name
     
      ' your code to do whatever you need goes here
  Next pi
End SubYes - I loop through each particular client file - perform a calculation and write a copy to a file before moving to the next clientAre you trying to filter the PivotTable for each different client, Dave?
Sub Pivot_Loop()
  Dim pt As PivotTable
  Dim pi As PivotItem
  Dim rGrandTotal As Range
 
  Set pt = ActiveSheet.PivotTables("ClientAccounts")
  For Each pi In pt.PageFields("Client ID").PivotItems
      pt.PageFields("Client ID").CurrentPage = pi.Name
     
        With pt.TableRange1
            Set rGrandTotal = .Cells(.Cells.Count)
            If rGrandTotal <= 100000000 Then
                DataWritetoSummary False
                SaveRelationshipCopy
                CopyRange
                UnhideRandC
            End If
           
        End With
     
     
  Next pi
End Sub
I'd have a thousand tabsDo you know that EXcel can automatically create separate copies of pivots - one for each item in a PivotFilter - and put them in separate tabs? It's called 'Show Report Filter Pages'
http://www.pivot-table.com/2012/10/29/create-worksheet-for-each-pivot-item/

 - probably produce hair like Chandoo's ..
 - probably produce hair like Chandoo's ..
I'd like to add :I liken it to someone who has a horse and cart who wants you to make it into a motor car, while keeping the horse and the cart as part of the running gear
Jeffrey, Me Old China!Dave, my man....can you post a sample file?
