Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Automatically running Macros

  Asked By: Dana    Date: Nov 02    Category: MS Office    Views: 728
  

I have an application where I need to do a web query every minute. I
got some code out of the book "Excel Hacks" which initially worked but
now runs the macro twice in the same minute. No matter what I do, I
can't seem to change this. This is my code:

In "ThisWorkbook":

Private Sub Workbook_BeforeClose(Cancel As Boolean)
End Sub
Application.OnTime dTime, "Get_Financial", , False
End Sub

Private Sub Workbook_Open()

End Sub
Application.OnTime Now + TimeValue("00:01:00"), "Get_Financial"
End Sub



In the module:

Sub Get_Financial()

Dim Index As Integer

dTime = Now + TimeValue("00:01:00")
Application.OnTime dTime, "Get_Financial"


I would much appreciate any ideas.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Adelfrid Fischer     Answered On: Nov 02

Did you tried to use 'F8' button properly to run the code  line by line to see
what happens. Maybe you tried, than you can ignore this answer. But when i have
this kind of problems, mostly i solve it with this.

 
Answer #2    Answered By: Barabas Cohen     Answered On: Nov 02

Insted of writing code  like a expert, you can do it in very simple way.
Step1: After fetch the data into excel  sheet using web  query.
Step2: Click right mouse button, and select Data Range Properties | Referesh
Control
Step3: and Set Referesh Every 1 min

 
Didn't find what you were looking for? Find more on Automatically running Macros Or get search suggestion and latest updates.




Tagged: