Adjust Time

M

Martin Wheeler

Win xp, xl2003

For some reason when I do a web query the time sometimes comes across as AM
when it should be PM. I have looked at the html code and there is no
designated AM or PM.
So what I am trying to do is to check the time and if necessay change it
from AM to PM.
I have tried the code below but it is not working.

Dim AnyString, Time
Time = Range("C2").Value
If Right(Time, 1) = "A" Then
Right(Time, 2) = "P"
End If

The format is H:mm with not AM/PM designation but once it has been copied
from the web query it looks like 12:35:00 PM or 12:35:00 AM

Any help would be greatly appreciated.
Ta,
Martin
 
T

Tim Barlow

Martin,

If the time is stored in the cell as a number (rather than text) then just
add 0.5 (half a day) to it:

If Range("C2") < 0.5 Then
Range("C2") = Range("C2") + 0.5
End If

HTH

Tim
 
M

Martin Wheeler

Hi Tim,
Thanks for that. It is not quite what I want but it has me thinking and I
can modify it.
Ta,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top