i am trying to convert a number into decimals of a foot in excel. here is my formula
=IF(C2="", "",ROUND(LEFT(C2,FIND("-",C2)-2)+SUBSTITUTE(REPLACE(C2,1,FIND("-",C2),""),CHAR(34),"")/12,4))
If Cell C2 is 41-9, it returns 4.75
it works fine except when excel automatically changes cell c2 to a date such as 8-8. any ideas?
Format C2 as text before you enter the value. Then it won't convert to date.
But your formula will still not work, because it does not handle single digits for the foot measure well. The single digit will result in a blank text result from the Left() function, which causes an error when that blank text is added to the extracted number of the Substitute bit.
Wrap an N() function around the Left(), which will turn a blank result into a zero, and then the formula works (given the cell format is text, not date).
=IF(C2="", "",ROUND(N(LEFT(C2,FIND("-",C2)-2))+SUBSTITUTE(REPLACE(C2,1,FIND("-",C2),""),CHAR(34),"")/12,4))
Related
I need to first convert a DEC into HEX and then apply a special display mask to the final cell display. With the formula below I can get this done OK for all HEX values that are strictly numbers, but whenever letters are included only the original HEX value gets displayed.
Decimal number is located in cell A1
Current formula is =TEXT(DEC2HEX(A1),"0000\.0000\.0000\.0000)
Working example:
If A1 = 8414472
Then HEX = 806508
Then formatted result correctly shows: 0000.0000.0080.6508
Where it breaks:
If A1 = 3672686
Then HEX = 380A6E
The Formatted result shows original/unformatted HEX value: 380A5E
Instead of the desired: 0000.0000.0038.0A5E
Example of more inputs and results:
Screenshot of more examples
How can I construct the =TEXT(value,[format_text]) formula to work on alphanumeric input as well as numeric only?'
If you have the TEXTJOIN function in your version of Excel, you can use the following formula:
edited to simplify formula
=TEXTJOIN(".",,MID("000000" &DEC2HEX(B1,10),{1,5,9,13},4))
If your Hex number is out of range of the DEC2HEX function, the formula will return an error.
The largest number returnable by this formula =>0000.007F.FFFF.FFFF
Use the Formula Evaluate tool to see how this works, if it is not clear to you.
If you do not have the TEXTJOIN function, you can concatenate each portion of the array formed by the MID function separately.
I have a bunch of time data that's formated weirdly, ranging from numbers 100 (representing 1 AM, or 01.00.00) to 2359 (representing 11.59PM, or 23.59.00).
I have been trying to use the TIMEVALUE() function to convert these data, but it just returns #Value?, I guess because the time format 'HHMM' is not recognized without the ' : ' separating them?
What I'd like is to convert it to the HH:MM:SS format, where the SS would automatically be zero.
Use REPLACE:
=--REPLACE(A1,LEN(A1)-1,0,":")
Then format it as desired.
If your text values are consistent, this can be carried out by using a formula that splits the value by the number of characters and then recombines the split values into a time value.
All formulas assume that your weirdly formatted text value is in cell B2
=IF(LEN(B2)>3,LEFT(B2,2),LEFT(B2,1))
This formula works out the first (hour) element of a time, if the text string is greater than three characters it will take the first 2 characters of the string (23), if its less than 3 characters it will only take the first character (1)
=RIGHT(B2,2)
This formula takes the second (minute) element of the time.
=TIME(C2,D2,0)
Finally this formula converts the two text elements into a string
C2 = The cell with formula 1 in it
D2 = The cell with formula 2 in it
This could all be written as the following formula if needed
=TIME(IF(LEN(B2)>3,LEFT(B2,2),LEFT(B2,1)),RIGHT(B2,2),0)
I am attempting to add three cells which I have formatted as hh:mm:ss
and it is giving me incorrect sum as one of them is missing hh
A B c
01:01:01 :01:01 01:01:01 SUM(A,B,C)
is returning 2:02:02 when it should be 2:03:03
I have several cells missing the HH so it is throwing off all my formulas, any way I can force the 00:01:01, on a cell that is :01:01?
Try,
=SUMPRODUCT(TIMEVALUE(RIGHT("00:00"&TEXT(A2:C2, "[hh]:mm:ss;#"), 8)))
The format mask used by the TEXT function (hh:mm:ss;#) converts real time values to text-that-looks-like-time and leaves values that are already text-that-looks-like-time unchanged. Leading zeroes and a colon are concatenated onto the result as a prefix and the right-most eight characters are parsed off with the RIGHT function. This should cover both :00:00 and :00 text values. This allows the TIMEVALUE function to process the resulting text to a true time value. The SUMPRODUCT wrapper produces cyclic calculation so that you don't have to sum three largely redundant formulas.
In the following sample image, note the default left alignment of B2 indicating text while A2 and C2 are right aligned indicating a true number, date or time.
If the values will always be contiguous as you show, you can try:
=SUMPRODUCT(--("00"&A1:C1))
Prepending "00" and the double unary will have no affect on the real time values, but will convert the "missing hour" value to a real time
I have a cell that has the formula =INDIRECT(CHAR(COLUMN()+65)&ROW())*MONTH($A$1)/12 where INDIRECT references an integer and $A$1 is a date. For some reason, the MONTH part converts the entire cell into a date instead of a number. How do I change the formula to have it return a number in number format? (Manually changing each cell through the ribbon is not an option for me).
I haven't tested this (and I can't comment till I get 50 rep), but you could wrap the whole thing in a text formula, then multiply by 1:
=TEXT(INDIRECT(CHAR(COLUMN()+65)&ROW())*MONTH($A$1)/12,"#")*1
Hope this helps!
Following is the which I am trying :
Let this number 6,123,456.33 in Cell A1,
Then in Cell B1 use this formula =TEXT(A1,"#,###,###.##"), will give you 6,123,456.33.
Then in Cell C1 use this formula = SUBSTITUTE(B1,",",".") ,will give you 6.123.456.33
Then in Cell D1 use this formula =","&RIGHT(H12,2), will give you ,33.
Then again come to Cell C1 Do text to columns or other options to remove the last digits with decimals and then concatenate result with Cell D1 shows the last three digits.
This tip will ends up in 6.123.456,33
But Problem is in point no. 5.
How should I remove .33 from cell C1?
TRUNC is not working on C1.
Any Suggestions ?
Seems like you don't mind having the result as text (and I can't seem to find a way to custom format it...) and as such, you can use the formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(A1,"#,###.00"),",","#"),".",","),"#",".")
There's a triple substitution, one to remove , for # (a dummy character), second to change . to ,, then last from the dummy # to ..
If A1 is always a 7 digit number with 2 decimals then you could use TEXT function like this:
=TEXT(A1*100,"0\.000\.000\,00")