Extracting information from a text string

-emma-

Board Regular
Joined
Jul 14, 2006
Messages
184
Office Version
  1. 365
Platform
  1. Windows
Hi all,

We get information sent to us in a text format and I'm looking to put this into a more manageable and easier to sort method. It is staffs shift pattern and is laid out as below.

A1 = 9.30am to 5.30pm
B1 = 5:00PM

(B1 = commitment time)

Ideally I would like A2 to pull out the start time (09:30) and B2 to pull out the end (17:30) - please note the time format change. Then B3 to display the information from B1 in the same time format (17:00).

I need these in time formats as I need to work out various things, such as time worked (B2-A2) etc.

Hope this makes sense.

Happy for any help at all.

Thank you in advance!

Emma
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi Emma, try this. I'm sure there are more elegant ways to achieve it but this appears to work.
A1 = 9.30am - 5.30pm

A2 = Start Time
=IF(UPPER(MID(A1,FIND(" ",A1)-2,2))=UPPER("AM"),0&SUBSTITUTE(LEFT(A1,FIND(" ",A1)-3),".",":"),TIME(HOUR(0&SUBSTITUTE(LEFT(A1,FIND(" ",A1)-3),".",":"))+12,MINUTE(0&SUBSTITUTE(LEFT(A1,FIND(" ",A1)-3),".",":")),SECOND(0&SUBSTITUTE(LEFT(A1,FIND(" ",A1)-3),".",":"))))

B2= End Time
=IF(UPPER(RIGHT(A1,2))="AM",0&SUBSTITUTE(MID(A1,FIND("-",A1)+2,(LEN(A1)-(FIND("",A1,FIND("-",A1))+1)-2)),".",":"),TIME(HOUR(0&SUBSTITUTE(MID(A1,FIND("-",A1)+2,(LEN(A1)-(FIND("",A1,FIND("-",A1))+1)-2)),".",":"))+12,MINUTE(0&SUBSTITUTE(MID(A1,FIND("-",A1)+2,(LEN(A1)-(FIND("",A1,FIND("-",A1))+1)-2)),".",":")),SECOND(0&SUBSTITUTE(MID(A1,FIND("-",A1)+2,(LEN(A1)-(FIND("",A1,FIND("-",A1))+1)-2)),".",":"))))

Format both cells as hh:mm

Have a play around with it and see if it meets your needs.
 
Upvote 0

Forum statistics

Threads
1,224,748
Messages
6,180,721
Members
452,995
Latest member
isldboy

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