Refresh Pivot and select name from drop down box

hanz753

Board Regular
Joined
Aug 9, 2017
Messages
53
Hello, I have a repetitive task in excel, I need to refresh a pivot table select the name and copy and paste data. This is what I have done so far.

Sheets("Pivot").Select
Range("B15").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").CurrentPage = _
"Alan O'Neill"

Sheets("Targets").Select
Range("B5").Select
Selection.Copy
Application.Goto Reference:="Alan_ONeill"

Sheets("Pivot").Select
Range("B22").Select
Application.CutCopyMode = False
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").CurrentPage = _
"Andrew Ferry"

Sheets("Targets").Select
Selection.Copy
Application.Goto Reference:="Andrew_Ferry"

I need to know how to refresh and select the name in the drop down box.

Kind Regards
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
This is how to refresh a pivot table:
Code:
Sub PivotRefresh()


    Dim pt As PivotTable


    Set pt = ActiveSheet.PivotTables("YourPivot")
    pt.RefreshTable


End Sub

Depending on what kind of Drop Down you have the code could be different. Is the Dropdown?:

1. Data Validation List
2. Form Control ComboBox
3. ActiveX ComboBox
 
Upvote 0
I am not sure how to tell which drop box it is.

To refresh the pivot, How would I include your code into my mine?

Much Appreciated
 
Upvote 0
Is the drop box in a cell? Or is it on top of the worksheet? When you right click it what name does it have in the upper left hand corner?
 
Upvote 0
Hello,

The drop box is not at the top of the worksheet and name in the upper name in the upper left hand corner says "Drop Down 14".

The drop box is big and cover 12 cells.

Thank you
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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