Splitting cells based on content

rholdren

Board Regular
Joined
Aug 25, 2016
Messages
140
Office Version
  1. 365
  2. 2019
Hi everyone hope it's an excellent day.

I did find something similar to what I was looking for on the site but don't quite understand what they were doing.
https://www.mrexcel.com/forum/excel...t.html?highlight=splitting+cell+based+content

This is my problem. I get a usage report from a vendor and in column C is the time a user spent logged on. The problem is sometimes
Column D has 1 hr 12 min 23 sec and sometimes it has 14 minutes and sometimes it's just 50 sec. The times vary. When the file is downloaded as a SCV the format of the column is general. I have tried converting text to columns but that sometimes puts hrs min and sec in the same column so if I tried to add the time up for each department it would make 1 hr 1 min 1 sec look like 3 hours. Here is how it looks

A B C D
User Name User Full Name Usage Dept
JoeScnmoe@123.com Joe Schmoe 1hr 15 min 32 sec ACCT
JillSchmoe@123.com Jill Schmoe 38 min FIN
BillieBobb@123.com Billie Bob 55 sec ACCT

If I convert text to columns I would have 94 hrs 15 min 32 sec So far I have tried a combination of text to columns before and after using find and replace with replacing the hr min sec with : I've got roughly 600 users in this system and I have to calculate each departments usage from a variety of internal and external users. Also formatting seems to be an issue. If I format the cells with hh:mm:ss it won't show anything larger than 24 hours correctly and if I format with d:hh:mm:ss it would show 50 hours as 2 days but will not show the rest of the time correctly. I think if the cells could be split correctly the rest of the issues would fall into place. Any help would be greatly appreciated.

Thanks.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi,

I'm not sure exactly what you're asking, but if it's a matter of formatting the result cell to show hours, minutes, seconds, then use [h]:mm:ss
It will show hours greater than 24.
 
Upvote 0
In the first example the time is all in one column but if you split it out (convert text to columns) minutes and seconds will line up under hours
[TABLE="width: 538"]

<tbody>[TR]
[TD="width: 37%"]
Username
[/TD]

[TD="width: 26%"]
User's Name
[/TD]

[TD="width: 24%"]
Usage
[/TD]

[TD="width: 13%"]
Dept
[/TD]

[/TR]

[TR]
[TD="width: 37%"]
JoeScnmoe@123.com
[/TD]

[TD="width: 26%"]
Joe Schmoe
[/TD]

[TD="width: 24%"]
1hr 15 min 32 sec
[/TD]

[TD="width: 13%"]
ACCT
[/TD]

[/TR]

[TR]
[TD="width: 37%"]
JillSchmoe@123.com
[/TD]

[TD="width: 26%"]
Jill Schmoe
[/TD]

[TD="width: 24%"]
38 min
[/TD]

[TD="width: 13%"]
FIN
[/TD]

[/TR]

[TR]
[TD="width: 37%"]
BillieBobb@123.com
[/TD]

[TD="width: 26%"]
Billie Bob
[/TD]

[TD="width: 24%"]
55 sec
[/TD]

[TD="width: 13%"]
ACCT
[/TD]

[/TR]

</tbody>[/TABLE]


[TABLE="width: 826"]

<tbody>[TR]
[TD="width: 33%"]
Username
[/TD]

[TD="width: 11%"]
User's Name
[/TD]

[TD="width: 15%"]
Usage
[/TD]

[TD="width: 7%"][/TD]

[TD="width: 5%"][/TD]

[TD="width: 6%"][/TD]

[TD="width: 5%"][/TD]

[TD="width: 5%"][/TD]

[TD="width: 7%"][/TD]

[TD="width: 5%"]
Dept
[/TD]

[/TR]

[TR]
[TD="width: 33%"]
JoeScnmoe@123.com
[/TD]

[TD="width: 11%"]
Joe Schmoe
[/TD]

[TD="width: 15%"]
1hr 15 min 32 sec
[/TD]

[TD="width: 7%"]
1
[/TD]

[TD="width: 5%"]
hr
[/TD]

[TD="width: 6%"]
15
[/TD]

[TD="width: 5%"]
min
[/TD]

[TD="width: 5%"]
32
[/TD]

[TD="width: 7%"]
sec
[/TD]

[TD="width: 5%"]
ACCT
[/TD]

[/TR]

[TR]
[TD="width: 33%"]
JillSchmoe@123.com
[/TD]

[TD="width: 11%"]
Jill Schmoe
[/TD]

[TD="width: 15%"]
38 min
[/TD]

[TD="width: 7%"]
38
[/TD]

[TD="width: 5%"]
min
[/TD]

[TD="width: 6%"][/TD]

[TD="width: 5%"][/TD]

[TD="width: 5%"][/TD]

[TD="width: 7%"][/TD]

[TD="width: 5%"]
FIN
[/TD]

[/TR]

[TR]
[TD="width: 33%"]
BillieBobb@123.com
[/TD]

[TD="width: 11%"]
Billie Bob
[/TD]

[TD="width: 15%"]
55 sec
[/TD]

[TD="width: 7%"]
55
[/TD]

[TD="width: 5%"]
sec
[/TD]

[TD="width: 6%"][/TD]

[TD="width: 5%"][/TD]

[TD="width: 5%"][/TD]

[TD="width: 7%"][/TD]

[TD="width: 5%"]
ACCT
[/TD]

[/TR]

</tbody>[/TABLE]
 
Upvote 0
You can try this type of a formula even if your data is not split into columns. Result is just the number of hours. And cut it down further if your have time in one column.

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][th]
C
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]User Name[/td][td]User Full Name[/td][td=bgcolor:#FFFF00]Result[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]JoeScnmoe@123.com [/td][td]Joe Schmoe 1hr 15 min 32 sec ACCT[/td][td]
1.258889​
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]JillSchmoe@123.com[/td][td]Jill Schmoe 38 min FIN[/td][td]
0.633333​
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td]BillieBobb@123.com[/td][td]Billie Bob 55 sec ACCT[/td][td]
0.015278​
[/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet3[/td][/tr][/table]

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
C
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]
=IFERROR(MID(B2,FIND("hr",B2,1)-2,2),0)+IFERROR(MID(B2,FIND("min",B2,1)-3,2),0)/60+IFERROR(MID(B2,FIND("sec",B2,1)-3,2),0)/3600​
[/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet3[/td][/tr][/table]
 
Last edited:
Upvote 0
That worked well. How would you adjust it if sometimes there is say 1 hr but sometimes in the range it might be double digits like 11 hrs. By the way I really appreciated this. I would have never thought of that. I was trying everything from using find and replace then converting text to column to lookups and finds and I just reached an end. Thank you
 
Upvote 0
Hi,

The division numbers in the formula in Post #4 is incorrect, and will not give you correct results.

Below is corrected version, and also will accommodate Single and/or Double digit Hours, Minutes, Seconds:


Book1
ABCDE
1UsernameUser's NameUsageDeptformatted hh:mm:ss
2JoeScnmoe@123.comJoe Schmoe1hr 15 min 32 secACCT01:15:32
3JillSchmoe@123.comJill Schmoe38 minFIN00:38:00
4BillieBobb@123.comBillie Bob55 secACCT00:00:55
5JoeScnmoe@123.comJoe Schmoe11hr 5 min 2 secACCT11:05:02
6JillSchmoe@123.comJill Schmoe8 minFIN00:08:00
7BillieBobb@123.comBillie Bob5 secACCT00:00:05
8JillSchmoe@123.comJill Schmoe38 min 3 secACCT00:38:03
9BillieBobb@123.comBillie Bob1hr 55 secFIN01:00:55
10JoeScnmoe@123.comJoe Schmoe1hr 15 minACCT01:15:00
Sheet35
Cell Formulas
RangeFormula
E2=IFERROR(MID(0&C2,SEARCH("hr",0&C2,1)-2,2)/24,0)+IFERROR(MID(0&C2,SEARCH("min",0&C2,1)-3,2),0)/1440+IFERROR(MID(0&C2,SEARCH("sec",0&C2,1)-3,2),0)/86400


E2 formula copied down.
 
Upvote 0
it works really well but it only shows this 5:15:32
with this 15 hr 15 min 32 sec
Single digits and the format come out perfect - I really appreciate the help.
(you guys are amazing) I learn more and more on this BB. One of these days I hope to be able to answer questions to help others.
 
Upvote 0
You have a space there in front of "hr", this should fix that problem:


Book1
ABCDE
1UsernameUser's NameUsageDeptformatted hh:mm:ss
2JoeScnmoe@123.comJoe Schmoe1hr 15 min 32 secACCT01:15:32
3JillSchmoe@123.comJill Schmoe38 minFIN00:38:00
4BillieBobb@123.comBillie Bob55 secACCT00:00:55
5JoeScnmoe@123.comJoe Schmoe11hr 5 min 2 secACCT11:05:02
6JillSchmoe@123.comJill Schmoe8 minFIN00:08:00
7BillieBobb@123.comBillie Bob5 secACCT00:00:05
8JillSchmoe@123.comJill Schmoe38 min 3 secACCT00:38:03
9BillieBobb@123.comBillie Bob1hr 55 secFIN01:00:55
10JoeScnmoe@123.comJoe Schmoe1hr 15 minACCT01:15:00
1115 hr 15 min 32 sec15:15:32
Sheet35
Cell Formulas
RangeFormula
E2=IFERROR(MID(0&C2,SEARCH("hr",0&SUBSTITUTE(C2," ",""))-2,2)/24,0)+IFERROR(MID(0&C2,SEARCH("min",0&C2)-3,2),0)/1440+IFERROR(MID(0&C2,SEARCH("sec",0&C2)-3,2),0)/86400


Edit: Removed "start number" (1) in formula, not needed, makes for slightly shorter formula.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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