VBA Code to use between for the Filter options in a Pivot Table

jessesingh

New Member
Joined
Mar 14, 2017
Messages
2
Dear Excel Gurus,


i am trying to arrange in my excel template a way where the VBA code can select a between range for a date range.

eg.


PromiseShip Date is the filer option and the range that i would like to select is 06/03/2017 - 12/03/2017.

The data set is coming from the SQL Cube, here is my code:

Dim wb As Workbook
Set wb = ThisWorkbook


Dim DATAD, Report, sales, MB, Cover As Worksheet


Set DATAD = wb.Worksheets("DATAD")
Set Report = wb.Worksheets("Report Setup")
Set MB = wb.Worksheets("MBData")
Set Cover = wb.Worksheets("Cover Sheet")


Dim Count, j As Integer


Application.ScreenUpdating = False


'Filtering Date in Sales table in DataD
Dim startDate As String
Dim endDate As String

DATAD.Select
startDate = Range("E1").Value
endDate = Range("D1").Value
pvtField.PivotFilters.Add Type:=xlDateBetween, Value1:=startDate, Value2:=endDate


Set sales = wb.Sheets.Add(After:=Sheets("DATAD"))
sales.Name = "Sales"
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,215,945
Messages
6,127,851
Members
449,411
Latest member
adunn_23

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