Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am getting the time, minute by minute from the US Naval
Observatory Master Clock Time. Occasionally, (five times today), I fail to get a time and in these circumstances, I would like to use the previous time obtained + 1 minute. I thought I'd got the code correct, but that doesn't seem to be the case. When I fail to get a time from the website it shows as "00:00" and not the previous time +1 so that when I try later in the procedure to refer to "RightTime", I get "Run-time error 1004". I would be grateful if someone could have a look at the code and point me in the right direction. Thanks Martin ===========Start Code============================= Dim NavyTimePos1 As Integer Dim NavyTimePos2 As Date Dim NavyTimeString As String Dim RightTime As Date NavyTimePos1 = 0 NavyTimePos2 = 0 NavyTimeString = "" RightTime = 0 'Finds the string "UTC/GMT" and sets NavyTimePos1 to 'the position of the string within the webpage NavyTimePos1 = InStr(IE_1.document.body.innerhtml, NavyTimeString) 'Counts back 9 from NavyTimePos1 (String position) 'and gets the string containing UTC time NavyTimePos2 = Mid(IE_1.document.body.innerhtml, NavyTimePos1 - 9, 5) NavyTimeRng.Offset(0, 1).Value = NavyTimePos2 'If time is not 0 If NavyTimeRng.Offset(0, 1).Value < 0 Then 'Because UTC time is one hour behind present U.K. time 'adjust the UTC time With NavyTimeRng.Offset(0, 1) .Value = .Value + TimeValue("01:00:00") .NumberFormat = "hh:mm" End With Else 'If NavyTimeRng.Offset(0, 1) = 0 Then NavyTimeRng.Offset(0, 1) = NavyTimeRng.Offset(-4, 1) + TimeValue("00:01:00") NavyTimeRng.Offset(0, 2).Value = "US Navy Time (Adjusted) and working as expected" End If 'Set correct time as "RightTime" to be used for all others RightTime = NavyTimeRng.Offset(0, 1) ==============End Code=========================== |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Time calculations for Scheduled Time vs. Actual Time Worked | Excel Discussion (Misc queries) | |||
straight time, time and a half, and double time | Excel Discussion (Misc queries) | |||
Calculate Ending time using Start Time and Elapsed Time | Excel Worksheet Functions | |||
template or formula for start time -finish time -total hours ple | New Users to Excel | |||
Calculating days & time left from start date/time to end date/time | Excel Worksheet Functions |