title: How to display a MsgBox in case of error 1004
body: <p>Created this code to change pivot fields in 4 different workbooks.</p>
  <pre><code>Option Explicit
  
  Sub Account_Name()
      
      Workbooks.Open &quot;C:\Book1.xlsm&quot;
      Workbooks.Open &quot;C:\Book2.xlsx&quot;
      Workbooks.Open &quot;C:\Book3.xlsx&quot;
      Workbooks.Open &quot;C:\Book4.xlsx&quot;
  
      Dim workbookNames As Variant
      workbookNames = Array(&quot;Book1.xlsm&quot;, &quot;Book2.xlsx&quot;, &quot;Book3.xlsx&quot;, &quot;Book4.xlsx&quot;)
      
      Dim i As Long
      For i = LBound(workbookNames) To UBound(workbookNames)
          
          Dim wb As Workbook
          Set wb = Workbooks(workbookNames(i))
          
          Dim ws As Worksheet
          Set ws = wb.Worksheets(&quot;Analysis&quot;)
          
          Dim rootAccount As String
          rootAccount = ws.Cells(1, 6).Value
  
          Dim pt As PivotTable
          For Each pt In ws.PivotTables
              With pt
                  With .PivotFields(&quot;Root Account&quot;)
                      .ClearAllFilters
                      .CurrentPage = rootAccount
                  End With
              End With
              Next pt
      Next i
  
  End Sub
  </code></pre>
  <p>Code is working fine until Root Account is found in all 4 workbooks but if any Root Account is not available in any of the workbooks it gives Runtime Error 1004.  In such case, is it possible to clear filter from Root Account and display MsgBox that this Root Account is not available. TIA</p>