How to manually piece together a fraction on excel - excel

I'm working with some tallies and would like to manually piece together a fraction that could be read using conditional formatting.
The extracted formula that uses fractional values are as follows:
COUNTIFS(Converter!40:40,"Y",Converter!$5:$5,F$5) & " / " & COUNTIFS(Converter!40:40,"Y",Converter!$5:$5,F$5) + COUNTIFS(Converter!40:40,"N",Converter!$5:$5,F$5)
Basically, the fraction should look like a/(a+b) and I would like all tallied figures to be displayed where applicable, i.e. 2/8 or 20/100.
Unfortunately Excel is only reading this as a date, even if I use the TEXT() formula, the figures continue to be read by Excel as dates.
I'd like the conditional formatting to turn red for any figure that's short of "1".
How can I get Excel to read the figures as a fraction? Any assistance would be greatly appreciated!

You should leave formatting as a visual aspect that is displayed versus something you should control in your formulas.
What you need to do is select the cell you want to format as a fraction.
Then you select the fraction amounts that you want.
Edit: If you want to fix the denominator then you need to use a custom format.

Unfortunately I couldn't get the fractions to work as fractions, luckily what I needed it to do was trigger the conditional formatting, so I ended up using the following conditional formatting formula.
It's a little longer but got me there in the end...
=AND(RIGHT(D1,(FIND(" ",D1,1)-1))>0,LEFT(D1,(FIND(" ",D1,1)-1))=RIGHT(D1,(FIND(" ",D1,1)-1)))

Related

Excel - Use formula/calculation within a Number Format

How do I put a formula in a Custom Number Format in Excel? For example (random example for illustration purposes),
Assume I have the following data:
INPUT
OUTPUT
Without editing the actual data in the cells, I would like to display the value in the cell divided by 2, and with two decimal places:
Is there a way to do this directly in the Custom Number Format, i.e. Without adding helper columns/cells doing the division calculation. NB. the part that has me stumped is doing the division calculation in the Number Format
Thanks!
The answer is NO, if you want to do it through custom format in a cell directly.
However, there is workaround in pivot table using calculated field option as shown below:
By the way I am curious why you want to show the number in a value other than its true value in a cell? This is not a good practice which could lead to misuse of the data in my humble opinion.
I have been wanting to display my min/60 as minutes, but the decimal is necessary for calculations. The best way I've found so far is to use conditional formatting in fractions.
0/60 "min" would display. 21666666 as 13/60 min
Which is what the cell formula was. It's only useful for around an hours worth of time, but if I come up with something to more clearly display a calculation of such as 8.5hrs as 8hrs 30min I'll update.

Convert text date/time to a real date time in excel

My data is extracted from an application and it has a text that looks like a date/time in excel. How do I actually convert "3/24/2016 11:22:07 PM" (in text) to a real date/time conversion? I've tried formatting the cells but it doesn't work.
For a date conversion:
=DATEVALUE(TEXT(A1,"MM/DD/YYYY"))
For a time conversion:
=TIMEVALUE(TEXT(A1,"HH:MM:SS"))
For datetime conversion:
=DATEVALUE(TEXT(A1,"MM/DD/YYYY"))+TIMEVALUE(TEXT(A1,"HH:MM:SS"))
Where A1 has the data you wish to convert.
By the way, then you may wish to format the cell to a date/time or whatever.
Hope that helps.
1) try using the DATEVALUE function and see if that works for you.
2) A more reliable way, since datevalue does not always work is to strip the text out manually and insert it into and excel date value. You are going to want to use a combination of the following functions:
DATE
TIME
IF
FIND
MID
LEFT
RIGHT
LEN
Now in my opinion the easiest way to do this is to work with multiple helper columns to build out all the steps. One column per step. When you get your final answer, you can substitute or copy paste your formulas from the helper columns into the final formula until you are left with one variable. The reason I say this is that the final formula referring to only 1 variable gets rather lengthy/ugly and very hard to trouble shoot if you make a typo, forget a bracket or something goes wrong. When I did this approach I used a totally of 14 columns (includes final formula). When I packed it all up into 1 formula it resulted in this:
DATE(RIGHT(LEFT(A3,FIND(" ",A3)-1),4),LEFT(LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))-1),MID(LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))+1,FIND("/",LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))+1)-FIND("/",LEFT(A3,FIND(" ",A3)-1))-1))+TIME(LEFT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1)+IF(AND(LEFT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1)<12,RIGHT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),2)="AM"),0,12),MID(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1,FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1)-FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1),MID(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1)+1,2))
Note it is set up using cell A3 as the one with the time as text that needs formatting.
3) You should also be able to use excel's text to column function located on the DATA ribbon about half way across.
4) And of course there will be a way to code it through VBA as an option as well.
=DATEVALUE(A1)+TIMEVALUE(A1) seems to work as well, since each function only returns the value corresponding to what it recognizes in the string. That is, DATEVALUE() ignores the time component, while TIMEVALUE() ignores the date component.

Excel formatting to correct dp

I'm looking to format excel cells such that whatever number I put in is the value it displays. i.e. at the moment when typing in 0.69374767047, the value it reads as is 0.69374767. But I also have numbers like; 0.00305 which come out correctly. Is there a way to format the cell so whatever number I put will come out to the correct decimal place and also that there is no 0s on the end of the number, as I need to do things later with that. Any help would be greatly appreciated.
Actually you can do it without code, just custom cell format and put 0.,### so it will give at least an integer and any dp if needed.
e.g.
Input Output
12 12
4.305 4.305
3.2 3.2

Determining cell format in excel

This seems to be so simple of a request, but I was not able to find an answer. I have a numeric cell and it seems to round numbers. Can I ask excel to tell me formatting settings of a particular cell. For example if the number formatting is fraction up to one digit I would like to know that. It would also be nice to know what the other attributes are; like width, centering, and so on.
You can get some information using the cell function (doc), but it's not as useful as one hopes...
You need to use VBA for more details.

How do I add a zero after the decimal when coding in excel

I am having trouble adding a zero after the decimal when coding in excel. The number that is being output is 240 and I want it to say 240.0. I have tried the round function in excel however that is only working when I have something like 242.46 and it gaves me 242.5.
Try:
oWrkSheet.Cells(110, 17).NumberFormat = "0.0"
It can work for many other numeric formats. See this post for more informations.
You can use a formula:
=TEXT(A1,"0.0")
Either change A1 to the appropriate cell, or surround the cell in question with a =TEXT(...,"0.0")

Resources