How to Auto Update with Interval 5 Seconds in Excel: 4 Ideal Examples

Method 1 – Auto Update Cell Every 5 Seconds with Excel VBA

Steps:

  • Go to the Development tab.
  • Select Visual Basic.

Auto Update Cell Every 5 Seconds with Excel VBA

  • The VBA window will pop out.
  • Select the Insert tab.
  • Click Module from the drop-down.

  • The Module window will appear.
  • Copy the following code and paste it into the box.
Sub UpdateCell()
   Worksheets(1).Calculate
   Range("C4").Calculate
   Application.OnTime DateAdd("s", 5, Now), "UpdateCell"
End Sub

  • Save the file.
  • Press the F5 key to run the code.
  • It’ll refresh cell C4 every 5 seconds.


Method 2 – Apply VBA Code to Refresh Cell Range with Interval 5 Seconds

Steps:

  • Go to Development ➤ Visual Basic.
  • Click Insert ➤ Module.
  • The Module window will emerge.
  • Copy the below code and paste it.
Sub UpdateCellRange()
    Worksheets(2).Range("C4:C7").Calculate
   Application.OnTime DateAdd("s", 5, Now), "UpdateCellRange"
End Sub

Apply VBA Code to Refresh Cell Range with Interval 5 Seconds

  • Save the code and press F5.
  • It’ll run the code.
  • The cell range C4:C7 will get updated every 5 seconds.


Method 3 – Automatically Update Excel Worksheet Using VBA

Steps:

  • Repeat the steps in example 1 or 2 to get the Module window.
  • Copy the code and input it there.
Sub UpdateSheet()
    Worksheets(3).Calculate
   Application.OnTime DateAdd("s", 5, Now), "UpdateSheet"
End Sub

Automatically Update Excel Worksheet Using VBA

  • After saving the file, press F5.
  • The 3rd worksheet will be refreshed every 5 seconds.


Method 4 – Auto Refresh Excel Workbook with Interval 5 Seconds

Steps:

  • Get the Module dialog box by repeating the steps in example 1.
  • Place the following code in the Module box.
Sub UpdateWorkbook()
Worksheets(1).Calculate
Worksheets(2).Calculate
Worksheets(3).Calculate
Worksheets(4).Calculate
Application.OnTime DateAdd("s", 5, Now), "UpdateWorkbook"
End Sub

Auto Refresh Excel Workbook with Interval 5 Seconds

  • This code will refresh all 4 worksheets you have in the workbook.

Download Practice Workbook
Download the following workbook to practice by yourself.


Related Article


<< Go Back to Refresh Excel Sheet | Excel Worksheets | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Aung Shine
Aung Shine

Aung Shine completed his bachelor’s in Electrical and Electronics Engineering from Bangladesh University of Engineering and Technology. It has been almost 2 years since he joined SOFTEKO and actively working on the ExcelDemy project. Currently he works as a Team Leader where he guides his team members to create technical content. He has published 150+ articles and reviewed 50+ articles. He has also solved various user problems before. He has interests in Data Analysis, Power Query, Advanced Excel,... Read Full Bio

2 Comments
  1. Reply
    Evaggelos Anastasiadis Sep 23, 2022 at 1:18 PM

    Hi Aung,

    Thanks for the code, could you also indicate a way to stop the update at a given time?

    • Hi EVAGGELOS,

      Thanks for your comment. I am replying on behalf of Exceldemy. Unfortunately, you can’t stop the update at a given time. But you can stop it instantly using a slightly different code and keyboard shortcut. You can follow the steps below for that purpose.

      STEPS:

      1. Copy and Paste the code in the Module window:

      Public RunWhen As Double
      Sub UpdateCell()
      RunWhen = Now + TimeValue("00:00:05")
      Application.OnTime RunWhen, "UpdateCell"
      Application.Calculate
      End Sub
      Sub StopUpdate()
      On Error Resume Next
      Application.OnTime RunWhen, "UpdateCell", , False
      End Sub

      2. Press Ctrl + S to save it.
      3. Now, press Alt + F8 to open the Macro window.
      4. Select StopUpdate from there and then, click on Options. It will open the Macro Options box.

      6. In the Macro Options box, type K in the “Shortcut Key” field.
      7. Then, click OK to proceed.

      8. Now, run the UpdateCell code.
      9. To stop updating, press Ctrl + K and the update will be stopped.

      I hope this will help you solve your problem. Please let us know if you have any other queries.
      Thanks!

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo