Hi, I have recorded a macro to filter a pivot table based on 3 different arrays. The important point is I want use these 3 arrays into a loop which firstly do the report filter 'master flow' based on first array for eample here ar(). Then it will do the row label 'eqp_type' filter based on array bar(). Lastly it will do the column label 'Layer group' filter based on array var(). Then copy the average value and go to another sheet in the same workbook. In this sheet I have thousand number of datas but no pivot table. Here it will also do the filtering based on the above arrays and put the copied value in the corresponding cell. I need help regarding this issue.

Thanks in advance.

The recorded vba code is following:

Sub Macro4()
ar() = Array("a", "28A-AMD_HK-DCL_11ML-81002_LV", "28HPP_HK-DCL_10ML-53020_ALR-RS", _
"28LPH-BCM_HK-DCL-SCE_10ML-8001UTM_ALR-RS", "28LP-QCT-TN3_SION-TG_ESIGE_7ML-5011_ALR-RS", _
"28LPS-MTK_7ML-60010_ALR-RS", "28SHP_HK-DCL_12ML-6312_LV", "28SLP_HK-DCL_7ML-5002_ALR-RS", _
"28SLP-ROC_HK-DCL_8ML-52010_ALR-RS", "40LP-BRCM_6ML-500UTM_ALR-RS")

var() = Array("b", "Contact", "Contact Long", "DI-BEOL Long", "FET Lower Trench", _
"Gate", "Gate Long", "Gate Short", "Implant Long", "Intermediate Trench", _
"Intermediate Via", "Lower Trench", "Spacer", "Spacer Short", "STI", "STI Long", _
"Stressed Liner", "Stressed Liner Long", "Upper Trench", "Upper Via", "post gate", "pre gate")
bar() = Array("c", "CDS_V4", "CDS_V2", "CDS10H", "CDSCG5")
ActiveSheet.PivotTables("MyPT").PivotFields("Master flow").ClearAllFilters
ActiveSheet.PivotTables("MyPT").PivotFields("Master flow").CurrentPage = _
"28A-AMD_HK-DCL_11ML-81002_LV"
With ActiveSheet.PivotTables("MyPT").PivotFields("eqp_type")
.PivotItems("CDS_V2").Visible = False
.PivotItems("CDS10H").Visible = False
.PivotItems("CDSCG5").Visible = False
End With
With ActiveSheet.PivotTables("MyPT").PivotFields("Layer group")
.PivotItems("Contact Long").Visible = False
.PivotItems("DI-BEOL Long").Visible = False
.PivotItems("FET Lower Trench").Visible = False
.PivotItems("Gate").Visible = False
.PivotItems("Gate Long").Visible = False
.PivotItems("Gate Short").Visible = False
.PivotItems("Implant Long").Visible = False
.PivotItems("Intermediate Trench").Visible = False
.PivotItems("Intermediate Via").Visible = False
.PivotItems("Lower Trench").Visible = False
.PivotItems("Lower Via").Visible = False
.PivotItems("post gate").Visible = False
.PivotItems("pre gate").Visible = False
.PivotItems("Spacer").Visible = False
.PivotItems("Spacer Short").Visible = False
.PivotItems("STI").Visible = False
.PivotItems("STI Long").Visible = False
.PivotItems("Stressed Liner").Visible = False
.PivotItems("Stressed Liner Long").Visible = False
.PivotItems("Upper Trench").Visible = False
.PivotItems("Upper Via").Visible = False
.PivotItems("(blank)").Visible = False
End With
Range("C6").Select
Selection.Copy
Sheets("cddata").Select
ActiveSheet.ListObjects("Table_CDS_Modell_for_Shawn").Range.AutoFilter Field _
:=2, Criteria1:="28A-AMD_HK-DCL_11ML-81002_LV"
ActiveSheet.ListObjects("Table_CDS_Modell_for_Shawn").Range.AutoFilter Field _
:=5, Criteria1:="M3_CDSem_V4i"
ActiveSheet.ListObjects("Table_CDS_Modell_for_Shawn").Range.AutoFilter Field _
:=7, Criteria1:="Contact"
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
Range("I2848").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.AutoFilter
Sheets("Pivot").Select
End Sub