Hello!

I have a pivot table which I have automated from a data set. There is only one field in the “row labels” and one field in the “∑ values” field. The following code works perfectly every time. However, I need to make the code dynamic in case there is an instance where one of the PivotItems isn’t contained in the data set. For instance, if there is no “BD2” in the dataset, then the following code will error out. What I need is if the code errors out since there is not a “PivotItem” contained in the dataset, then skip that line of code and continue to the next. This would be a HUGE help! Thank you so much!

With ActiveSheet.PivotTables("ItemList").PivotFields("Business Day")
    .PivotItems("BD1").Position = 1
    .PivotItems("BD2").Position = 2
    .PivotItems("BD3").Position = 3
    .PivotItems("BD4").Position = 4
    .PivotItems("BD5").Position = 5
    .PivotItems("BD6").Position = 6
    .PivotItems("BD7").Position = 7
    .PivotItems("BD8").Position = 8
    .PivotItems("BD9").Position = 9
    .PivotItems("BD10").Position = 10
    .PivotItems("BD11").Position = 11
    .PivotItems("BD12").Position = 12
    .PivotItems("BD13").Position = 13
    .PivotItems("BD14").Position = 14
    .PivotItems("BD15").Position = 15
    .PivotItems("BD16").Position = 16
    .PivotItems("BD17").Position = 17
    .PivotItems("BD18").Position = 18
    .PivotItems("BD19").Position = 19
    .PivotItems("BD20").Position = 20
    .PivotItems("BD21").Position = 21
    .PivotItems("BD22").Position = 22
    .PivotItems("BD23").Position = 23
End With