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: 113
Default Remove specific text from cell string

Im trying to run a macro to look at imported time data in a cell,
remove the am/pm designation and convert the time to 24 clock.

For now I will just select the range of data and run the macro...
the imported data is in general format example: "953am"

My though is to run through the column (selection) test each cell
value and if the cell contains the string "pm", remove "pm" and add
1200 to the numeric value.

If the cell contains "am" then just remove am.

just to get findingt he string right I started with:

Sub FixTime()
Dim timeCell As Range

For Each timeCell In Selection
If timeCell.Value = Right("pm", 2) Then
timeCell.Value = timeCell.Replace("pm", "")
End If

Next
End Sub

However, all the cells with "pm" in them get bypassed
any help will be appreciated.

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 11:39 PM.

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"