HI all, i am using the code below to control PivotTable1.
Cell B4 contains a drop down box based on a validation list, this controls the pivot field SpecDesc and this is activated by a command button.
What I cant figure out, is that i have the following cells which i also want to control other pivot fields.
They are:
cell B5 which will control the Pivot Field DivCode
cell B6 which will control the pivot field ConsCode
cell B7 which will control pivot field AdmCode
and B8 which controls DayCode.
What I am trying to get is a macro that would update the pivot table based on each of these fields unless the value in the B cell is (All)...ie nothing has been selected in which case that field is left as (All)
Private Sub CommandButton1_Click()
Call updatepivot
End Sub
Sub updatepivot()
Dim SpecDesc As Range
Set SpecDesc = Range("B4")
For Each cell In SpecDesc
ActiveSheet.PivotTables("PivotTable1").PivotFields("SpecDesc").CurrentPage = cell.Value
'MsgBox ""
Next cell
End Sub
Hope someone can help.
Thanks
Luce
Bookmarks