Need VBA code to for pivot to select particular date and data related to the date

suyogpat

New Member
Joined
Jun 29, 2017
Messages
28
Hi All,

I have a daily task where from pivot i have to select yesterday's date and copy the data into another sheet.. is there any way by which i can use macro for the same. What i Do daily is
1- from pivot i select yesterdays date from "create date" column and then copy the data in another sheet.

i am trying to achieve here is in output cell of "A1" i will have ysterday's date , macro should pick up that date , and run the same in pivot of "create date", (which is column J), Then 2nd condition is he should filter "pitched,Mandate" from "stage" column which is column C, if he found any data then, it should be copied to another sheet. if no data found macro should copy only pivot headers.

below is the test data.. I am sorry that i can not attach file here..so just copying the pivot Data here.. thanks all in advance for your help. appreciate your input for the same.

Mandate Date(All)
Lost Date(All)
Sum of Sub ID Rev
Sub IDFinal Family NameStageCountryMemberAMTeamE/GProd Level 2Create DateClose DateTotal
11223353sodexo-1MANDATEnepaltest10(blank)mid corpEtest1001/04/201902/04/201998687
11223352dell-1COMPLETEDladakhtest9(blank)small corpGtest902/04/201902/04/201987545
11223346facebook-1DEADgoatest3(blank)Large CorporateGtest302/04/201901/04/201969874
11223345Asian Paints-1MANDATEMumbaitest2(blank)Large CorporateGtest201/04/201915/04/201958687
11223350calender-1DONE AWAYhyderabadtest7(blank)small corpGtest701/04/201901/04/201956987
11223349end-1COMPLETEDchennaitest6(blank)mid corpEtest602/04/201915/04/201952689
11223348stat-1PROSPECTINGBangaloretest5(blank)small corpGtest501/04/201903/04/201942698
11223347gmail-1DONE AWAYDelhitest4(blank)Large CorporateEtest402/04/201902/04/201942159
11223344Nerolac-1PITCHEDIndiatest1(blank)Large CorporateGtest102/04/201903/04/201915487
11223351avaya-1PROSPECTINGkolkatatest8(blank)mid corpEtest801/04/201902/04/20192444
(blank)(blank)(blank)(blank)(blank)(blank)(blank)(blank)(blank)(blank)(blank)
Grand Total527257

<tbody>
</tbody>
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hello,

Most probably your Field : Create Date is used as a Page filter ...

Code:
[COLOR=#303336][FONT=inherit]Sheets[/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"Sheet1"[/FONT][/COLOR][COLOR=#303336][FONT=inherit]).[/FONT][/COLOR][COLOR=#303336][FONT=inherit]PivotTables[/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"PivotTable1"[/FONT][/COLOR][COLOR=#303336][FONT=inherit])[/FONT][/COLOR][COLOR=#303336][FONT=inherit] _
[/FONT][/COLOR][COLOR=#303336][FONT=inherit]        [/FONT][/COLOR][COLOR=#303336][FONT=inherit].[/FONT][/COLOR][COLOR=#303336][FONT=inherit]PivotFields[/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"Create Date"[/FONT][/COLOR][COLOR=#303336][FONT=inherit]).[/FONT][/COLOR][COLOR=#303336][FONT=inherit]CurrentPage [/FONT][/COLOR][COLOR=#303336][FONT=inherit]=[/FONT][/COLOR][COLOR=#303336][FONT=inherit] Date-1[/FONT][/COLOR]

Hope this will help
 
Upvote 0
Hi James,

Thanks for the quick reply, but here i am looking to have two pivot fields.. as 1st criteria is "Create Date" and 2nd pivot filter should be on "stage",I need to select 2 conditions from stage column along with the create date..
and also if there is no data available for the previous date i need macro to copy only headers else should copy the data..

Thanks again in advance.
 
Upvote 0
Hi,

Without the file rather difficult to progress ...

An easy solution is for you to start your macro recorder ...

and go through your process once ...

Then, on that basis ... you will improve your macro ...

Hope this will help
 
Upvote 0
I have created a one pivot table. but not select in yesterday date. please kindly support.
 
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,235
Members
449,092
Latest member
SCleaveland

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