Pivot Table Macro For Weekly Stats Updates.

Pax2Pax

New Member
Joined
Feb 22, 2015
Messages
1
Hi everyone,

I am very new to programming, only having dipped my toe into Python and VBA recently. I have a data set from work that I plug into my first sheet.

In my macro I:

1) Create a filter and filter the data.
2) Copy and Paste Special to a different sheet to only have the values from the filter.
3) Create a Pivot table from that data.

Now, at this point I start having some issues. I first tried creating a new sheet, and posting the pivot table in there hoping to delete the sheet at the end of the macro. That gets held up when I rerun the macro because it creates a sheet with a number 1 higher than the sheet it created before. I then thought to create a Pivot Table by selecting create new sheet but the same problem occurs. Then I tried having the sheet already there before the macro starts recording. The sheet no longer becomes the issue but the Pivot Table now creates the error because of the new Pivot Table name.

Having seen some basic tutorials online and answers from here I know I face two challenges so this is what I want to know:

1) How do get the sheet the macro creates to be the same sheet name each time to avoid the error above?
2) How do I get the Pivot Table name to be the same each time so that the same problem does not happen there?

Thank you for your time.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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