Add Button to Refresh all Worksheets

amazeballs

New Member
Joined
Apr 24, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a macro setup that captures all of the sheet names in a workbook, and puts it on a Contents page (sheet 1).

It's working great however it doesn't automatically refresh when a user changes sheet names. I have to ask users to manually press Ctrl+ Alt + F9 each time they open the workbook.

I'm looking to add a "Refresh" button on the first sheet which refreshes all the data for them.

I've inserted the button and entered the below code however it's not refreshing the data. Can anyone assist?

Thank you :)


Private Sub CommandButton1_Click()
ActiveWorkbook.RefreshAll
MsgBox "Sheet Names have been refreshed!"
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi,
why not just call your first macro from the button click?
 
Upvote 0
Right click the button, click Assign Macro and select your refresh macro.
 
Upvote 0
The above instruction works for a shape.
Just insert a simple shape, like a rectangle, and assign the macro to it as above.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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