+ Reply to Thread
Results 1 to 4 of 4

Bring back certain number of characters before a particular letter or number

Hybrid View

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    Hinckley, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Bring back certain number of characters before a particular letter or number

    Good Morning everyone,
    long time member, but have never posted!

    I have a problem I just cannot solve, I have a list of data provided to me which falls like the below and is based on time spent using a system:

    1h 32m 5s
    54m 8s
    7h 54m 4s

    Is there a way I can use a formula to bring back the characters before "h" which I can change to use it for "m & s" too?
    I have been fiddling with the MID and LEFT coupled with FIND but cannot get the result I need.

    Using text to columns does not work in this instance as i need all the hours in one column and minutes in another and so on.
    I just need a way to quickly separate the results into three columns one for H one for M and one for S??

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,937

    Re: Bring back certain number of characters before a particular letter or number

    If you have your data A1 try below formula in B1
    =IFERROR(TRIM(RIGHT(SUBSTITUTE(" "&LEFT(A1,SEARCH("M",A1)-1)," ",REPT(" ",10)),10))+0,"")
    =IFERROR(TRIM(RIGHT(SUBSTITUTE(" "&LEFT(A1,SEARCH("M",A1)-1)," ",REPT(" ",10)),10))+0,"")
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

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

    Re: Bring back certain number of characters before a particular letter or number

    Try this to get the hours part:

    =IF(ISNUMBER(SEARCH("h",A1)),--MID(" "&A1,SEARCH("h"," "&A1)-2,2),0)

    then the minutes part becomes:

    =IF(ISNUMBER(SEARCH("m",A1)),--MID(" "&A1,SEARCH("m"," "&A1)-2,2),0)

    and the seconds part:

    =IF(ISNUMBER(SEARCH("s",A1)),--MID(" "&A1,SEARCH("s"," "&A1)-2,2),0)

    Copy these down as required.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    09-11-2012
    Location
    Hinckley, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Bring back certain number of characters before a particular letter or number

    Thank you very much, not sure I'd have been able to get that!

+ 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. Replies: 6
    Last Post: 05-11-2015, 10:25 AM
  2. [SOLVED] right find to bring back only a number
    By namluke in forum Excel General
    Replies: 5
    Last Post: 01-20-2015, 09:14 AM
  3. Array Formula Lookup - Bring back Lowest Date + Bring Back Cell Location
    By Matt1998 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-04-2014, 12:08 PM
  4. [SOLVED] Formula to bring back a number if X is Y or Z
    By jonathan.haynes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-18-2013, 08:03 AM
  5. Replies: 4
    Last Post: 10-12-2010, 02:12 AM
  6. Bring Back Multiple Items Based on Common Number
    By 3ric in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2007, 02:44 PM
  7. [SOLVED] worksheet columns changed from letter to number, how change back
    By Ron in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-09-2005, 04:06 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