Macro not changing Pivot Table dates correctly

ABCDH

New Member
Joined
Sep 30, 2009
Messages
12
This macro was written to change the date in two pivot tables whenever a date is changed in a dropdown box. The date is a defined name range called "DteSelect." The two Pivot Tables and the Dropdown box are in the same sheet 'Dashboard.' The data is located in other sheets.

When the date is changed in the dropdown, the pivot tables report filter is pulling in the wrong date.

Any help to solve this would be appreciated!
Amber


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pvt As PivotTable

If Union(Target, Range("DteSelect")).Address = Range("DteSelect").Address Then
Worksheets("Dashboard").PivotTables("PivotTable1").PivotFields("Date").CurrentPage = Range("Date").Value

If Union(Target, Range("DteSelect")).Address = Range("DteSelect").Address Then
Worksheets("Dashboard").PivotTables("PivotTable6").PivotFields("Date").CurrentPage = Range("Date").Value

If Not Intersect(Target, Range("DteSelect")) Is Nothing Then
    Application.Run "EquityChart"
End If
End If
    Application.Run "PivotTable"

Sheets("Dashboard").Range("DteSelect").Select
Application.ScreenUpdating = True
End If
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,548
Messages
6,125,472
Members
449,231
Latest member
Sham Yousaf

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top