macattackpro
Board Regular
- Joined
- Nov 27, 2017
- Messages
- 55
Hi Gurus,
First, I'm fairly new to VBA but have realized it is the only way to accomplish what I'm trying to do and 100% willing to learn.
What I have is a workbook with 3 different pivot tables. I'd like for a reference above each to say when that particular pivot table has been refreshed. I've found code that will work beautifully (below) but when I view the workbook online I see that VBA does not work. So the question becomes: How do I get this code to post to the cell the refresh date of a specific pivot table?
Thanks so much for your time!
First, I'm fairly new to VBA but have realized it is the only way to accomplish what I'm trying to do and 100% willing to learn.
What I have is a workbook with 3 different pivot tables. I'd like for a reference above each to say when that particular pivot table has been refreshed. I've found code that will work beautifully (below) but when I view the workbook online I see that VBA does not work. So the question becomes: How do I get this code to post to the cell the refresh date of a specific pivot table?
Code:
Option Explicit
Public Function LastPvtUpdate(rngCell As Range) As Variant
Dim cPvtCell As Range
Dim pvtTbl As PivotTable
On Error Resume Next
Set pvtTbl = rngCell.Cells(1, 1).PivotTable
If Err.Number = 0 Then
With pvtTbl
LastPvtUpdate = .RefreshDate
End With
Else
LastPvtUpdate = "Error: No Pivot Table Reference!"
End If
End Function
Thanks so much for your time!