troubleshooting Question

How to select latest date from VisibleItemList in Pivot table report that uses OLAP cube connection in excel

Avatar of reehalsoni
reehalsoni asked on
Visual Basic ClassicMicrosoft Excel
4 Comments1 Solution2013 ViewsLast Modified:
Folks,

I think this is going to be an easy one for those you have been dealing with Excel, VB and Pivot tables for longtime. I am sort of new and pushed into MS Sql server and now dealing with a report that has a column called SnapshotDt which users use to pull up historical data and we are using a excel template and refreshing this template daily with new data hence the snapshotdt column gets new dates very day. But the issue is the template is set for a particular date because one date has to be selected. Now users want me to dynamically update this sndpshotdt to the latest date when we run the refresh step which is where my issue is. I can do this manually by recording a macro but I need this done on daily basis which is where I am getting stuck and as was wondering if some one can take a look at this Macro and help me update the .&[ piece to pick up the latest date automatically.


Sub test4()
'
' test4 Macro
'

'
    Sheets("ContractReview").Select
    ActiveSheet.PivotTables("PivotTable2").PivotSelect _
        "'[Dim].[SnapshotDt].[SnapshotDt]'[All]", xlDataAndLabel, True
    Range("B4").Select
    ActiveSheet.PivotTables("PivotTable2").PivotFields( _
        "[Dim].[SnapshotDt].[SnapshotDt]").VisibleItemsList = Array( _
        "[Dim].[SnapshotDt].&[2009-12-13T00:00:00]")   - this 2009-12-13 needs to be replaced with a variable where this macro can get the latest date from snapshotdtand that's gets selected
End Sub



Any help on this will be a great
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros