Converting cell data with a formula

Devilfish2006k

Board Regular
Joined
Jun 7, 2006
Messages
80
If there is data in a cell that is formatted as '3yrs 6ms 23ds' and links to another cell in another workbook and I want the cell in the other workbook to display this period in days i.e. 1302, what formulae would you use? Many thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
what are the values in the source workbook for....

3 years 0 months 0 days
0 years 3 months 0 days
0 years 0 months 3 days
3 years 0 months 3 days
3 years 3 months 0 days
 
Upvote 0
Q1 Is the cell value a number formatted as described or does the cell contain text?

Q2 If the cell contains TEXT then I need to know how zeros are treated in the source workbook

3 years 0 months 0 days
Is it
3yrs
or
3yrs 0 ms 0ds

same for these
0 years 3 months 0 days
0 years 0 months 3 days
3 years 0 months 3 days
3 years 3 months 0 days

If the cell value is a number then ignore Q2
 
Upvote 0
Not exactly :confused:

Your reply suggests that the value in the cell is text (ie not a number and not the result of a formula)
- how are the 6 items listed in post#4 Q2 displayed?
 
Upvote 0
try these formulas in source file first to see if it provides the correct result
- assumes all data has this structure
[number][yrs][space][number][ms][space][number][ds]

years to days
=LEFT(A1,FIND(" ",A1)-4)*365

months to days
=RIGHT(LEFT(A1,SEARCH("ms",A1)-1),2)*30

days
=SUBSTITUTE(RIGHT(A1,4),"ds","")*1
(yes it is necessary to multiply by 1 :))

total days (add them together)
=LEFT(A1,FIND(" ",A1)-4)*365+(LEFT(A1,SEARCH("ms",A1)-1),2)*30+SUBSTITUTE(RIGHT(A1,4),"ds","")*1

(You could use 365.25 and 30.5 as multipliers and then ROUND the result to Zero decimal places to be more precise)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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