Excel formula to convert number to both feet and inches - excel

I have a spreadsheet (excel 2010) where in column A I have a metric value (2413mm) and in column B I need a formula that will convert 2413mm to show the feet/inches in the following format (7' 11")
I can do this if I use 3 or 4 columns to first convert the 2413 to 7.9', then extract the feet and inches into two separate columns and finally concatenate the separate feet and inches into a final cell.
I'd really like to be able to do all this within one cell.

I notice that Gary's Student's answer will give you decimals in the inches - if you want the answer to the nearest inch try this version
=INT(ROUND(A1*0.03937,0)/12)&"' "&MOD(ROUND(A1*0.03937,0),12)&""""

With data in A1, in B1 enter:
=INT(CONVERT(A1,"mm","ft")) & " '" & 12*(CONVERT(A1,"mm","ft")-INT(CONVERT(A1,"mm","ft"))) & """"

I wrote a User Defined Function to deal with feet and inches once and for all. I've shared the code and a downloadable VBA module here:
https://engineerstoolkit.wordpress.com/2017/03/05/dealing-with-feet-and-inches-in-excel/
If you install that, you can display the result (to any precision you desire) using the formula:
=FtToString(A1/25.4/12) Dividing by 25.4 converts the millimeters to inches, and dividing again by 12 converts it to feet (which is the assumed input for my formula).

Related

Bond Price fraction convert to decimal 32nd excel formula

i am pretty sure a lot of people in capital market experience this :
use excel formular to convert fraction to decial in 32nd
i know most case we just divide last 2 digits decimal place by 32 for example:
100-160= 100+16/32=100.5
100-200=100+20/32=100.625
but if 3 decimal places : 99-226=99+(22+6/8)/32=99.7109375
how do we convert it to formula in excel , please help!!!!
Assuming a data setup like this where your Bond Prices are in column A and your formula for Decimal Conversion is in column B:
The formula in cell B2 and copied down is:
=LEFT(A2,FIND("-",A2)-1)+(MID(A2&"00",FIND("-",A2)+1,2)+MID(SUBSTITUTE(A2,"+",4)&"000",FIND("-",A2)+3,1)/8)/32
Alternative Using FilterXML() function
Adding a further column B with the following xml conversion
="<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>"
you can calculate results in a next column via FilterXML() available in Excel 2013+:
=FILTERXML(B2,"//a")+(LEFT(TEXT(FILTERXML(B2,"//b"),"000"),2)+RIGHT(TEXT(FILTERXML(B2,"//b"),"000"),1)/8)/32
tl;tr - one column solution (just for fanatics)
Of course you could also force the xml base into one formula:
=FILTERXML("<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>","//a") + (LEFT(TEXT(FILTERXML("<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>","//b"),"000"),2)+RIGHT(TEXT(FILTERXML("<t><a>" &SUBSTITUTE(SUBSTITUTE(A2,"+","4"),"-","</a><b>")&"</b></t>","//b"),"000"),1)/8)/32

Format percentage with optional decimal places in Excel

I have some cells in Excel with decimal places in, which I want to format as percentages. However, I only want decimal places to appear if the decimals are non-zero. For example, I have many cells which contain numbers such as:
0.09
0.195
0.876
0.4
I would like these to be displayed as percentages in the form:
9%
19.5%
87.6%
40%
Any solutions would be greatly appreciated.
Format your column as percentage with your desired number of decimal places.
Then, to eliminate decimal places for those percentages that have only two significant numbers after the decimal point, use conditional format:
Rule Formula: (substitute your range to format for C1, or copy/paste the formatting from the cell you initially format.
=ABS(MOD(C1,0.01)) < 0.0000000001
And select Format ► Number ► Percent with zero decimal places
The comparison in the MOD formula above is to account for the occasional rounding errors in double precision math used by Excel. You may want to make that number smaller depending on the range of your data.
Written in Excel 2016 (Office 2016)
if "General" cell A1 contains 25 then use: (in B1)
= TEXT(A1, "[=0]0;[<1].000;General") & "%"
Result: 25%
if "Percentage" cell A1 contains 25.00% then use: (in B1)
= TEXT(A1 * 100, "[=0]0;[<1].000;General") & "%"
Result: 25% (no decimal point)
if "Percentage" cell A1 contains 25.50% then use: (in B1)
= TEXT(A1 * 100, "[=0]0;[<1].000;General") & "%"
Result: 25.5% (reduced to one decimal place, trims off all trailing zeros.)

Converting Feet-Inches to Inches Excel

Hi I have a large excel spreadsheet which contains heights of different athletes in the form of
6' 4.25"
6' 2.75"
I am stuck on trying to find a single formula that can convert all of these heights to strictly inches.
Any help would be greatly appreciated.
Because these are string text and not actual numbers we need to parse the data. The following will grab the parts of the string and convert to the number:
=LEFT(A1, FIND("'",A1)-1)*12 + MID(A1,FIND("'",A1)+1,LEN(A1)-FIND("'",A1)-1)
Here's a formula that handles feet and inches (5'10"), just feet (5'), just inches (60"), and a number representing inches (60). It's based on brettdj's version.
=IFERROR(IFERROR(CONVERT(LEFT(A1,FIND("'",A1)-1),"ft","in"),0)+IFERROR(SUBSTITUTE(RIGHT(A1,LEN(A1)-IFERROR(FIND("'",A1),0)),"""","")+0,0),A1)
Wanted to get CONVERT in there as it is an under-utilised function. Something like
=CONVERT(LEFT(A1,FIND("'",A1)-1),"ft","in")+SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND("'",A1)),"""","")
You could have the input in feet in one cell (say E4) and the input in inches in another cell (say F4, next to it). You can get your result by having a third cell (G4) with this formula:
= SUM(E4 * 12) + F4

how to add zeros after numbers to get a fix length in EXCEL

I have 3 numbers in excel.
A1. 498
A2. 899
A3. 5209
I want the numbers as the followings:
B1. 49800
B2. 89900
B3. 52090
I am still finding the solutions via online but most of the resource is discussing about leading zeros.
Please, could you kindly give me any ideas? Thanks.
I hope this formula may be of some use:
=A1 & REPT("0"; 5 - LEN(A1))
Thought this does not set the format of the cell itself (which I doubt can be done as you are changing the value of the cell by adding the zeros)
The formula only works if you are dealing with numbers as text, so you may need to convert them to text in the formula (TEXT(A1; "0") instead of A1)
you can do this one quite easily without VBA - using an IF and the very handy REPT function:
=IF(LEN(H13)<5,H13&REPT(0,5-LEN(H13)),H13)
Essentially - if the length is less than 5 - you repeat 0 up to the amount of times that its missing.
Seems like simple math to me. Essentially you want to shift left (base 10) a certain number of times. We can do this by:
Calculate the ceiling of the base-10 logarithm of the value to get it's "length"
Subtract the result from the target "length" of 5, this is the number of places we want to shift
Take 10 to this power and multiply back by the value.
In other words, where x represents the value in column A you want to transform:
In Excel, this would be expressed as:
=A1*POWER(10,(5-CEILING(LOG10(A1),1)))

Excel, getting values from the same row but different column

I'm trying to write a GPA calculator in Excel (LibreOffice really, but it works the same) and what I need help with is calculating quality points. I've only ever coded in C and similar languages, so spreadsheets and their notation are incredibly foreign to me.
In case you don't know, GPA is calculated by dividing your total quality points by your total credit hours, quality points being your grade set to a 4-scale in a particular class multiplied by the class's credit value. So, for example, if I got an B in a 4-hour class, I would get 3*4 = 12 quality points for that class. If I took a 17-hour semester and earned 63 quality points, my GPA for that semester is 63/17 = 3.706.
Getting to the point, my spread sheet is set up something like this
A B C
GRADE CREDITS QUALITY
1 B 3 9
2 A 4 16
3 B 1 3
...
so my formula would look something like this
IF(A1="A",4*B1,
IF(A1="B",3*B1,
IF(A1="C",2*B1,
IF(A1="D", B1,0))))
The problem is, this code will only work for row one. For any other row, I'd have to replace all the 1s with the row number being calculated. There must be a better way to write this formula. How would I go about generalizing this so I can just copy and paste the formula without editing it?
In Excel you can copy and paste a formula, or fill-down a formula and it will automatically update the references for you. Have you tried copying the formula down? Otherwise you can do indirect formulas that use commands like INDIRECT and ROW, but I cannot guarantee those will convert to LibreOffice.
If you need to use INDIRECT formulas, it'd look something like this:
=IF(INDIRECT("A" & ROW())="A",4*INDIRECT("B" & ROW()),
IF(INDIRECT("A" & ROW())="B",3*INDIRECT("B" & ROW()),
IF(INDIRECT("A" & ROW())="C",2*INDIRECT("B" & ROW()),
IF(INDIRECT("A" & ROW())="D", INDIRECT("B" & ROW()),0))))

Resources