In this article, you will learn how to auto refresh excel file every 1 second using VBA code.
Question): In column A there are some values stored & I want them to automatically refresh every 1 second.
To refresh excel file every 1 second we will follow the below steps:
This will create new module.
Enter the following code in the Module
Sub Calculate_Range()
Range("A1:A5").Calculate
Application.OnTime DateAdd("s", 1, Now), "Calculate_Range"
End Sub
In this way we can schedule the excel file to refresh every x amount of time & save.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.
Many many thanks! saved me from lots of frustration....
can you let me know how to refresh time for every 1 second
You can use OnTime events to refresh excel every 1 second.
sub RecalculateSheet()
application.calculate
end sub
sub calculculateEvery1Sec()
Application.ontime Now + (1 / 24 / 60 / 60), "RecalculateSheet"
end sub
Here is the brief and explanatory article about events in excel: Events in Excel VBA .
When I close the workbook that contains this VBA, it reopens automatically and according to the refresh interval stipulated. Only happens if I have another workbook open, as obviously that stops Excel from closing completely.
when i am trying to run it, it shows "syntax error"
please help
it say datetie not defined
let me see your code.