Fraction to decimal

A

Alvin

I have a cell with a value of {0'-3/4}
I want another cell to call that value and change the format to
{0'-0 3/4"}

the following code will change it to a decimal when it is formatted correctly:
which is what I am after.

{=SUBSTITUTE(LEFT(H69,FIND("-",H69)-1),"'","")*12+SUBSTITUTE(REPLACE(H69,1,FIND("-",H69),""),"""","")}

Thanks in advance
Alvin Smith
 
J

joel

You can add the text function to format the cell


{=Text(SUBSTITUTE(LEFT(H69,FIND("-",H69)-1),"'","")*12+SUBSTITUTE(REPLACE(H69,1,FIND("-",H69),""),"""",""),ANYFORMAT)}


the format would be in double quotes Like "General" or "0.00"
 
J

Joe User

Alvin said:
I have a cell with a value of {0'-3/4}
I want another cell to call that value and change
the format to {0'-0 3/4"}
[so] the following code will change it to a decimal
when it is formatted correctly: which is what I am after.

If you would prefer, replace your original formula with the following, which
handles all text of the form 1'-3/4", 1'-2 3/4" and 1'2":

=12*LEFT(A1,FIND(CHAR(39),A1)-1) +
(IF(ISNUMBER(FIND("/",A1)),
IF(ISNUMBER(FIND(" ",A1)),"","0 "), "") &
SUBSTITUTE(MID(A1,1+FIND("-",A1),99),CHAR(34),""))

You can replace CHAR(39) with "'" and CHAR(34) with """". I chose to use
CHAR because the string forms are difficult to read in some fonts.

Note: That is __not__ an array formula. Enter by simply pressing Enter,
not ctrl+shift+Enter. You put curly braces around the formula in your
original posting. I suspect that is your own meta-syntax to quote the
formula. But Excel uses curly braces in that way to denote an array formula.
So your intention is unclear.


----- original message -----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top