One of the most common questions we get from users is how to automate data refresh in Excel using a button. The good news is that it’s relatively easy to do using a bit of VBA code. In this blog post, we’ll walk you through the steps necessary to set up a button that will refresh your data with just a few clicks.

First, you’ll need to insert a button onto your worksheet. To do this, go to the Insert tab and click the Shapes drop-down. From there, select the Rectangle shape.

Once you have your button inserted, right-click it and select Assign Macro. This will open the Macro dialog box. Here, you’ll want to select the macro that you want to run when the button is clicked. If you don’t have a macro already created, you can click the New button to create one.

Once you have your macro selected, click the OK button. This will close the Macro dialog box and return you to your worksheet.

Now, it’s time to write the code that will actually refresh your data. This code will go in the macro that you selected in the previous step. The first thing you’ll want to do is declare some variables. We’ll need three variables: one for the workbook that contains the data, one for the worksheet that contains the data, and one for the range of cells that we want to refresh.

Next, we’ll use the Workbooks.Open method to open the workbook that contains our data. We’ll need to provide the full path to the workbook, so be sure to replace the placeholder text with the actual path to your workbook.

Once the workbook is open, we’ll use the Sheets.Find method to find the sheet that contains our data. Again, we’ll need to provide the full name of the sheet, so be sure to replace the placeholder text with the actual name of your sheet.

Now that we have a reference to the sheet that contains our data, we can use the Range.Refresh method to refresh the data. We’ll need to provide the range of cells that we want to refresh, so be sure to replace the placeholder text with the actual range of cells.

Once the data is refreshed, we’ll use the Workbook.Close method to close the workbook. We’ll set the SaveChanges argument to False so that we don’t prompt the user to save the workbook.

Finally, we’ll use the Application.Quit method to quit Excel.

And that’s it! Once you’ve added this code to your macro, you can test it out by clicking the button on your worksheet.

Other related questions:

How do I create a refresh button in Excel VBA?

Open the Visual Basic Editor (VBE)

Insert a new module

Paste the following code into the module

Sub Refresh()


End Sub

Save and close the VBE
Open the worksheet you want to add the button to
Insert a new shape

Right-click the shape and select Assign Macro

Select the Refresh macro and click OK

Close the macro dialog

How do I refresh an Excel sheet with a button?

Open the Excel spreadsheet that you want to refresh.

Click on the “Data” tab in the ribbon.

Click on the “Refresh All” button in the “Connections” group.

How do you refresh data in Excel VBA?

There are a few ways to refresh data in Excel VBA. One way is to use the “Refresh” method:


This will refresh all data sources in the workbook.

Another way is to use the “Calculate” method:


This will recalculate all formulas in the workbook.

How do I refresh Excel with power automated?

There is no specific command to refresh Excel with Power Automate. However, you can use the “Run a PowerShell script” action to run a script that will refresh your Excel workbook.

The following script will refresh all sheets in an Excel workbook:

$Excel = New-Object -ComObject Excel.Application

If you only want to refresh a specific sheet, you can use the following script:

$Excel = New-Object -ComObject Excel.Application
$Workbook = $Excel.Workbooks.Open(“C:\path\to\workbook.xlsx”)
$Worksheet = $Workbook.Sheets(“Sheet1”)


  • Was this Helpful ?
  • YesNo

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *