Good Afternoon,
I'm a newbie to ZBA and researched the error code. I believe the issue is with this line of code: Dim Sheet As Worksheet, SheetName$, MyFilePath$, N&. I understand the first part declares worksheet variable but not sure I follow the rest of it. As far as the next line of code goes the Pivot name is correct: ActiveSheet.PivotTables ("PviotTable1").PivotCache.Refresh ---> Run-time error pops-up on this line. I've pasted part of the Module below since it is fairly long. I appreciate any help or pointers in the right direction.
Sub filter_distr_report()
Dim newdist() As String
Dim LR, LR2, LR3, LR4 As Long
Dim lastrow2 As Long
Dim newtest, distnumb, actdate, distnotincluded As String
Dim bldate As Date
Dim worksheet_name As String
Dim filter, filter2, mmyyy, mm, yyyy As String
Dim Sheet As Worksheet, SheetName$, MyFilePath$, N&
'refresh report
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
'MyFilePath$ = ActiveWorkbook.Path & "\" & _
'Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4)
MyFilePath$ = ActiveWorkbook.Path & "\Top Dist PDFs"
' ReDim cdRack(0 To 1, 0 To 3) As String
' A CD rack for the Beatles
' cdRack(0, 0) = "Rubber Soul"
'to run in backlog/report macro as well as stand alon:
' check name of current sheet - if not "New Dist", then it is backlog/report
worksheet_name = ActiveSheet.name
Sheets("Top Dist").Activate
LR = ActiveSheet.Cells(Rows.count, 1).End(xlUp).Row
Bookmarks