Excel - Command Button to refresh Pivot tables

Asked By Ro on 17-Oct-07 12:22 AM
In case the users I will be sending my sheet to, do not have their pivot table
selected, how can I insert a command button that refreshes data, without them
having to select the red !

Thanks




j0n.v0nd3rh3yd3 replied on 17-Oct-07 08:13 AM
You can add a button from Forms:
View > Toolbars > Forms.
Then drag and drop "Button onto the sheet"

Then hit Alt+F11 > Insert > New Module
Add this code
Sub RePvt()
ActiveWorkbook.RefreshAll
End Sub

Go back to the button > right click > Assign Macro > RePvt

Note, this will refresh ALL pivot tables in the workbook.

Regards
Jon
--
Email: subst1tut3 numb3rs for l3tt3rs...
tro replied on 17-Oct-07 08:34 AM
Hi Ron,

Try using this line of code in the macro assigned to your button:

ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh

cheers,
troy.

Unprotect Any Spreadsheet... Without The Password... In Just Seconds
Get eXL_unProtect today for less than you'd pay for lunch!
www.eXtreme-eXcel.com
Don't Let Anyone Lock You Out Of A Spreadsheet Again!