0
在我的電子表格中,我有可變數據;然而,我有一組特定的屬性,我想在它們確實出現在當週的數據運行中時進行篩選。如果它們沒有出現,我想讓數據透視表過濾器跳過它並繼續下一步。 不幸的是,當我嘗試運行我的宏時,我不斷收到調試錯誤。誰能幫忙?VBA宏數據透視表過濾器錯誤
I.E. 如果「1G1N13S2」不在變量[原始]數據中,它會讓我直接進入VBA進行調試,而不是跳過它(無論是錯誤還是真實)以繼續進入後續ID#。
'PivotTable
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=ActiveSheet.UsedRange). _
CreatePivotTable TableDestination:="", TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
' BCA_Other Macro
With ActiveSheet.PivotTables("PivotTable1").PivotFields("ACTIVITY_ID")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables(_
"PivotTable1").PivotFields("SUM_$"), "Count of SUM_$", xlCount
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of SUM_$")
.Caption = "Sum of SUM_$"
.Function = xlSum
.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("WK_END_DATE")
.Orientation = xlColumnField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("WK_END_DATE")
.PivotItems("(blank)").Visible = False
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("ANALYSIS_TYPE")
.Orientation = xlPageField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").PivotFields("ANALYSIS_TYPE"). _
CurrentPage = "ACT"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("BUS_UNIT_GL_FROM")
.Orientation = xlPageField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").PivotFields("BUS_UNIT_GL_FROM"). _
CurrentPage = "AV"
'Activity ID Filter
With ActiveSheet.PivotTables("PivotTable1").PivotFields("ACTIVITY_ID")
.PivotItems("1G1N13S2").Visible = False
.PivotItems("1G1N2SAN").Visible = False
.PivotItems("1G1N5ACC").Visible = False
.PivotItems("1G1N5SCI").Visible = False
.PivotItems("1G1N5SDV").Visible = False
.PivotItems("1G1N5SMS").Visible = False
.PivotItems("1G1N5SST").Visible = False
.PivotItems("1G1N9BAT").Visible = False
.PivotItems("1G1N9EBT").Visible = False
.PivotItems("1G1N9EPL").Visible = False
.PivotItems("E6T66ZAV").Visible = True
.PivotItems("E6T66ZB3").Visible = True
.PivotItems("E6T66ZB4").Visible = True
.PivotItems("E6T66ZB5").Visible = True
.PivotItems("E6T66ZCU").Visible = True
.PivotItems("E6T66ZDX").Visible = True
.PivotItems("E6T66ZE9").Visible = True
.PivotItems("E6T66ZIL").Visible = True
.PivotItems("E6T66ZIS").Visible = True
.PivotItems("E6T66ZIV").Visible = True
.PivotItems("E6T66ZIZ").Visible = True
.PivotItems("E6T66ZJ6").Visible = True
.PivotItems("E6T66ZJ8").Visible = True
.PivotItems("E6T66ZJA").Visible = True
.PivotItems("EMAD0005").Visible = False
.PivotItems("EMADF006").Visible = False
.PivotItems("F8800YN5").Visible = True
.PivotItems("F8800YNU").Visible = True
.PivotItems("F8800YNW").Visible = True
.PivotItems("F8800YPM").Visible = True
End With
'Add new tabs for Hours and rename tabs to Dollars and Hours
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "BCA_Other_Dlrs"
Sheets("BCA_Other_Dlrs").Select
Sheets("BCA_Other_Dlrs").Copy Before:=Sheets(1)
Range("B18").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Sum of SUM_$").Orientation _
= xlHidden
With ActiveSheet.PivotTables("PivotTable1").PivotFields("SUM_HOURS")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable1").PivotFields("SUM_HOURS").Orientation = _
xlHidden
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables(_
"PivotTable1").PivotFields("SUM_HOURS"), "Count of SUM_HOURS", xlCount
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of SUM_HOURS")
.Caption = "Sum of SUM_HOURS"
.Function = xlSum
.NumberFormat = "#,##0.0_);[Red](#,##0.0)"
什麼是「調試錯誤」,它們在哪裏出現? – skrrgwasme 2014-08-28 15:41:01