I need help creating a user-defined function for the simple purpose of formating numbers.
Example
I have the following number:
119.50
I want the function to format the number to the following form:
119-16 (16/32 is 0.5 in the decimal, so the base for all calculations will be 32.
Another example:
I have the following number:
119.171875
I want the function to format the number to the following form:
119-05 + (the plus just says that 5.5 should be divided by 32)
The reason I want this is that if the number reaches a certain decimal it just becomes to long and ugly on sight.
My basic train of thought was to separate the integer from the decimal. And then work my way through the decimal.
1st got the decimal and multiplied by 32 to get the whole number from the decimal in the form of 0.25-31.75 (if the decimal from the decimal leftover is 0.25 =1/4, 0.5 = +, 0.75 = 3/4). So a number such as 5.75 would look like this -05 3/4. After that I simply put together many CONCATENATE functions to join the whole number and the formatted decimal. Need help in creating such function.
I have a huge code, but I actually want to create a function to automatically format the number and use less memory on the sheet.
Here is the code but worthless I might add:
Example
I have the following number:
119.50
I want the function to format the number to the following form:
119-16 (16/32 is 0.5 in the decimal, so the base for all calculations will be 32.
Another example:
I have the following number:
119.171875
I want the function to format the number to the following form:
119-05 + (the plus just says that 5.5 should be divided by 32)
The reason I want this is that if the number reaches a certain decimal it just becomes to long and ugly on sight.
My basic train of thought was to separate the integer from the decimal. And then work my way through the decimal.
1st got the decimal and multiplied by 32 to get the whole number from the decimal in the form of 0.25-31.75 (if the decimal from the decimal leftover is 0.25 =1/4, 0.5 = +, 0.75 = 3/4). So a number such as 5.75 would look like this -05 3/4. After that I simply put together many CONCATENATE functions to join the whole number and the formatted decimal. Need help in creating such function.
I have a huge code, but I actually want to create a function to automatically format the number and use less memory on the sheet.
Here is the code but worthless I might add:
Code:
=CONCATENATE(INT(O23),"-",IF(INT(((O23-INT(O23))*32))<10,CONCATENATE(0,INT(((O23-INT(O23))*32))),INT(((O23-INT(O23))*32)))," ",IF(((O23-INT(O23))*32)-IF(INT(((O23-INT(O23))*32))<10,CONCATENATE(0,INT(((O23-INT(O23))*32))),INT(((O23-INT(O23))*32)))=0.25,"1/4",IF(((O23-INT(O23))*32)-IF(INT(((O23-INT(O23))*32))<10,CONCATENATE(0,INT(((O23-INT(O23))*32))),INT(((O23-INT(O23))*32)))=0.5,"+",IF(((O23-INT(O23))*32)-IF(INT(((O23-INT(O23))*32))<10,CONCATENATE(0,INT(((O23-INT(O23))*32))),INT(((O23-INT(O23))*32)))=0.75,"3/4",""))))