+ Reply to Thread
Results 1 to 4 of 4

Calculations on numbers in text string

  1. #1
    Registered User
    Join Date
    07-31-2019
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    2

    Calculations on numbers in text string

    I have text strings in a column. I need to convert the numbers to a decimal, e.g. 1 hr 51 min 54 sec would equal 1.865. However some cells will not have anything in the hour (or theoretically minutes or seconds) so columns will look like this

    1 hr 51 min 54 sec
    17 min 12 sec

    etc.

    I used isnumber with search which worked when there was an hour a minute and a second number, but gave a value error for the second row here. Any ideas?

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Calculations on numbers in text string

    Hi, welcome to the forum

    Actually, to excel, 1 hr 51 minutes 54 sec would be 0.077708 not 1.865
    What you need to understand about dates and times in excel is…

    a date is just a number representing the number of days passed since 1/1/900...and then formatted in a way that we recognize as a date. So, for instance, today (Wed 31 Jul 2019) is actually 43677

    Time is actually a decimal part of 1 (day), so 06:00 AM is 0.25, 12 noon is 0.5 and 18:00 (or 6 PM) is 0.75

    Based on your sample...
    A
    B
    3
    1 hr 51 min 54 sec
    1:51:54
    4
    17 min 12 sec
    0:17:12

    B3=IF(ISNUMBER(FIND("hr",A3,1)),TIME(LEFT(A3,2),MID(A3,FIND("min",A3,1)-3,3),MID(A3,FIND("sec",A3,1)-4,3)),TIME(0,MID(A3,FIND("min",A3,1)-3,3),MID(A3,FIND("sec",A3,1)-4,3)))
    copied down
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    07-31-2019
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    2

    Smile Re: Calculations on numbers in text string

    Thank you, Fdibbins!

    I multiplied your formula by 24 to get back to the answer I needed and it works like a charm!. I appreciate the help!

    I'm excited to be a part of the forum and hopefully contribute what I've learned.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Calculations on numbers in text string

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. RE: Extracting Certain Numbers from a Text String Containing Several Numbers
    By EduardStoo in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-04-2018, 07:00 PM
  2. [SOLVED] Calculations involving text and numbers
    By kierand99 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-17-2018, 04:50 PM
  3. Replies: 4
    Last Post: 07-21-2014, 10:33 AM
  4. [SOLVED] extracting numbers from a string of text and numbers
    By ScottLor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-05-2013, 04:47 PM
  5. Replies: 0
    Last Post: 10-10-2012, 10:11 AM
  6. Performing calculations on a string of text
    By mljs54 in forum Excel General
    Replies: 5
    Last Post: 09-26-2011, 08:10 PM
  7. [SOLVED] Numbers stored as text prevent calculations
    By 525047 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-16-2006, 12:20 PM

Tags for this Thread

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