ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.OnTime driving me crazy (https://www.excelbanter.com/excel-programming/315285-re-application-ontime-driving-me-crazy.html)

Lars-Åke Aspelin

Application.OnTime driving me crazy
 
On 30 Oct 2004 21:26:22 GMT, Ron
wrote:

Hello vba gurus [green with envy, but learning]


I have a web query that needs refreshing periodically throughout the
day. Sometimes upto 20 times.
The web query URL is mostly static but has a 7 digit event number tagged
on the end.

i.e. http://webquery-site/market.asp?id=2211993

The url is static but the 7 digit number on the end changes every day,
and also several times through the day.

Ordinarily I do this manually but am going away for 2 weeks and want to
automate this so a friend can set it running on a morning and let it do
it's thing all day.

I have in column F a list of times ie 20:28:00 and in column H I have
the corresponding event id's ie 2211993, 2211994, 2211897 etc.

What I'm struggling with is getting the Application.OnTime procedure to
work correctly.

My code at the moment is..

Sub OnTimeTest()
Dim TimeCell2 As String
TimeCell2 = Sheets("test").Range("F2")
Application.OnTime TimeValue("TimeCell2"), "testProcedure"
End Sub


The variable TimeCell2 is the time that sits in cell F2.

The procedure "testProcedure" simply pops up a message box for now until
I get this right then I will link it to the sub that refreshes the
query.

I'm sure the solution is something simple but I'm at a loss now. I
think I'm going wrong on the syntax somewhere.

Any ideas guys?

Thanks

Ron


Hi Ron,

Try this:

Replace the "TimeCell2" argument to TimeValue with

Format(TimeCell2, "hh:mm:ss")

Hope this helps

Lars-Åke


All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com