#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Adjust Time

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Adjust Time

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


"Martin Wheeler" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Adjust Time

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



"Tim Barlow" wrote in message
...
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


"Martin Wheeler" wrote in message
...
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






Reply
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
Adjust macro puiuluipui Excel Discussion (Misc queries) 0 December 7th 09 10:32 PM
I need to adjust the date Irbe Excel Discussion (Misc queries) 2 April 30th 08 02:50 AM
How do I adjust a curve ? Mauro Charts and Charting in Excel 12 June 15th 07 06:35 PM
HELP - I need to adjust code!!!! jriendeau5[_3_] Excel Programming 1 November 5th 04 02:29 AM
Help needed coding a macro to adjust the source of information each time it is run lbauckman Excel Programming 1 November 4th 03 08:13 AM


All times are GMT +1. The time now is 02:16 AM.

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

About Us

"It's about Microsoft Excel"