LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Time and If...

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time calculations for Scheduled Time vs. Actual Time Worked The Caterer Excel Discussion (Misc queries) 1 November 29th 09 08:08 AM
straight time, time and a half, and double time Jeremy Excel Discussion (Misc queries) 3 September 23rd 08 09:03 PM
Calculate Ending time using Start Time and Elapsed Time Chief 711 Excel Worksheet Functions 5 May 13th 08 04:34 PM
template or formula for start time -finish time -total hours ple cc New Users to Excel 1 March 27th 06 06:06 PM
Calculating days & time left from start date/time to end date/time marie Excel Worksheet Functions 7 December 7th 05 02:36 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"