+ Reply to Thread
Results 1 to 6 of 6

Extracting characters from a text string - please help

  1. #1
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Extracting characters from a text string - please help

    Hi everyone,

    Could someone kindly assist with the following.

    I have a bunch of opening times for several libraries, all working according to their own schedule.

    The cells with their opening times look like:

    9.30am-7.30pm
    9.30am-7.30pm
    10.00am-7.30pm
    9.30am-7.30pm
    9.30am-7.30pm
    10.00am-3.45pm

    If I want to extract starting time, I can use LEFT formula, but what about finishing time? How can I tell Excel to look for 7:30, and then covert it to 19:30? Please can someone help?

    Thank you.
    Last edited by bookharin; 03-23-2015 at 10:47 AM.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Extracting characters from a text string - please help

    Assuming the Start time is always AM, and the End time is always PM..

    Try this
    Start Time: =SUBSTITUTE(SUBSTITUTE(LEFT(A1,FIND("-",A1)-1),".",":"),"am"," am")+0
    End Time: =SUBSTITUTE(SUBSTITUTE(MID(A1,FIND("-",A1)+1,99),".",":"),"pm"," pm")+0

    Format the cells with the formulas as a TIME.

  3. #3
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Re: Extracting characters from a text string - please help

    Quote Originally Posted by Jonmo1 View Post
    Assuming the Start time is always AM, and the End time is always PM..

    Try this
    Start Time: =SUBSTITUTE(SUBSTITUTE(LEFT(A1,FIND("-",A1)-1),".",":"),"am"," am")+0
    End Time: =SUBSTITUTE(SUBSTITUTE(MID(A1,FIND("-",A1)+1,99),".",":"),"pm"," pm")+0

    Format the cells with the formulas as a TIME.
    Awesome. Thank you so much. x

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Extracting characters from a text string - please help

    Here's one way (there are many others):

    =VALUE(SUBSTITUTE(MID(A1,FIND("-",A1)+1,4),".",":")&":00")+IF(RIGHT(A1,2)="pm",0.5,0)

    assuming your data starts in A1. Format the cell with the formula as a time in the style your prefer, then copy down.

    Hope this helps.

    Pete

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Extracting characters from a text string - please help

    You're welcome.

  6. #6
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    6

    Re: Extracting characters from a text string - please help

    Thank you, @Pete_UK

    Appreciate it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] extracting 1st 4 characters from a string
    By braintrain in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-18-2014, 01:48 AM
  2. [SOLVED] Extracting data between 2 characters in a text string
    By Donga00 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-14-2013, 10:35 AM
  3. extracting characters from string
    By johnmerlino in forum Excel General
    Replies: 6
    Last Post: 10-21-2010, 09:56 AM
  4. Extracting characters from a string
    By incognito in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-30-2007, 03:18 AM
  5. [SOLVED] Extracting a character from a string of characters
    By Sue in forum Excel General
    Replies: 6
    Last Post: 10-29-2005, 09:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1