VBA - Help With Date

excel_training_wheels

Board Regular
Joined
Aug 25, 2005
Messages
193
Hi-

I am trying to add a macro to update my pivot table based on dates I input. I input June 1 2011, and my formula converts it into the proper pivot table structure:

[2011].[Quarter 1].[June].[1]

I then have this as a VBA module

Sub ChangeDate()
Sheets("Test").Activate
For i = 1 To 1
With Sheets("Test").PivotTables("Test" & i)
.PivotFields("[BKGDate]").AddPageItem "[BKGDate].[All BKGDate]." & Sheets("Select").Cells(1, 7).Value, True
End With
Next i
End Sub

This works great. My goal, though, is:
1. Have the code filter the pivot table to year to date - based on the date I input (in this case Jan 1 - Jun 1)
2. Same date range for last year (for a year on year comparison).

Any ideas?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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