LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Remove specific text from cell string

Sorry, my example says "9pm" & "45pm" where I meant "am".

Mike F
"Mike Fogleman" wrote in message
m...
That's great! However I have one more question. Will you have to deal with
times between midnight and 1:00 AM? I have found in my experience that the
leading 0's are truncated off. 9 minutes after midnight may import as
"9pm", 45 minutes would be "45pm", etc. The code I gave you only works on
string lengths of 5 or greater ("100am"). More code is needed to check if
the string length is <5 and deal with the possibility that it is 3 or 4
characters in length.
If your situation fits this scenario, then post back with an example of
those times.

Mike F
"Robert H" wrote in message
ups.com...
I used:

Sub FixTime()
Dim timeCell As Range

For Each timeCell In Selection
If Right(timeCell, 2) = "pm" Or Right(timeCell, 2) = "am" Then
timeCell.Value = Left(timeCell, Len(timeCell) - 4) & ":" & _
Mid(timeCell, Len(timeCell) - 3, 2) & " " & Right(timeCell, 2)
timeCell.NumberFormat = "hh:mm"
End If
Next
End Sub

and it worked perfect. Thaks Mike and all for posting.
V/R
Robert






 
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
Nested formula to search a text string and return specific text Barbie Excel Worksheet Functions 10 February 21st 09 07:40 AM
extact text string from specific cell except three last characters markx Excel Worksheet Functions 3 October 23rd 07 02:40 PM
How do I remove all text in a cell after a specific character? Erik Millerd Excel Worksheet Functions 1 July 13th 05 03:17 PM
want to remove all text characters equal to one character in length from text string [email protected] Excel Worksheet Functions 1 April 18th 05 09:56 PM
want to remove all text characters equal to one character in length from text string [email protected] Excel Worksheet Functions 1 April 18th 05 12:25 AM


All times are GMT +1. The time now is 01:21 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"