Extract hour from all strings with time content

vladimiratanasiu

Active Member
Joined
Dec 17, 2010
Messages
346
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hello!

I have a table with cells including alphanumerical strings, hours and text formats. I need a formula to extract hours, from all cells where they are present. I found one solution (see attached table) that runs ok only if the type of content is alphanumerical, but it fails when it's formatted as time/hour only. Do you know any formula to do this task, meeting both the time and the alphanumerical formats and ignoring the text-only strings? Thank you!

Book2.xlsx
ABC
12108:04 
132OR  
14300:00 
154OR  
16500:00 
17608:00 
187ABCD 7:01 11117:01
198EFGH 11:50 222211:50
209IJKL 14:00 33414:00
Sheet1
Cell Formulas
RangeFormula
C12:C20C12=IFERROR(TRIM(MID(SUBSTITUTE(SUBSTITUTE(B12,")",""),".",""),FIND(":",B12)-2,FIND(":",REPLACE(B12,99,FIND(":",B12),""))-1)),"")
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
How about
Excel Formula:
=IFERROR(IF(ISNUMBER(B12),B12,--(TEXT(TRIM(MID(B12,FIND(":",B12)-2,5)),"hh:mm:ss"))),"")
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top