Excel 2016 seemingly randomly changes number values I enter - excel

Today I encountered a really weird error in Excel 2016 16.0 (on Windows 10.1) that is driving me crazy:
When I enter the number 2.089E-7 into a cell that is formatted as either standard, number, or scientific, excel changes the value to 2.09E-4.
When I click into the cell, the bar on top tells me the value of the cell is 0.0002089, which is exactly the number I entered, except that three decimal orders of magnitude are missing.
I played around a little bit and found out that Excel does this for all numbers that have more than three decimals in the format X.XXXE-7. If I enter, for example, 2.10E-07 the value is correctly stored as 0.00000021.
I have tried everything that came to my mind, including formatting the cell to all available types, closing and re-starting Excel.
What is wrong with my Excel version?
Thanks in advance!
EDIT for clarification:
Numbers I enter, vs. values that get stored:
2.1E-7 vs. 2.1E-7
2.11E-7 vs. 2.11E-7
2.111E-7 vs. 2.111E-4
2.1111E-7 vs. 2.1111E-3
2.11111E-7 vs. 2.11111E-2
and so on...

You are right to try formatting, because this seems like a formatting issue. Select your cell and try this button in the Ribbon and see if that works.

Related

How to manually piece together a fraction on 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)))

How to use an input mask in excel vba?

READ CAREFULLY THE QUESTION PLEASE, IT MENTIONS EXCEL VBA.
NOT EXCEL
I was given the task of fixing a date input on a VBA form. A textbox should have the user enter the date as MM/DD/YYYY.
I am required to use an input mask, not allowed to do something as validating date after or using a calendar. So far I was able to use the 2 methods mentioned (forcing the format after using ISDATE).
However, it has now been made clear it has to be a mask so keys are filtered on entry, with the mask being visible when entering the date: __/__/____
Where you see underscore, he should only be able to enter numbers and the / are always at those positions
Is there a way to do this? I can only find a tutorial for the mask in Access VBA.
I Googled "Excel input mask" and the 2nd result was: Using an Input Mask Microsoft Excel written by Allen Wyatt...
Using an Input Mask
...You may wonder if there is a way to set up an input mask that will add the colon automatically. The good news is yes, there is. The bad news is no, there isn't. Sound confusing? Let me explain...
You can set up a custom format that will display your time in any format you want. For instance, you could use the following steps:
Select the cells you want to use for time input.
Choose Format from the Cells menu. Excel displays the Format Cells dialog box.
Make sure the Number tab is displayed.
In the Category list, choose Custom.
Replace whatever is in the Type box with #":"00.
Click on OK.
You can now enter your times using just digits. The problem (and this is the bad news) is that the cell doesn't really contain a time. If you enter 230 (for 2:30), it doesn't contain 2:30 as a time—it contains two hundred and thirty. Thus, you can't use the contents of the cell directly in time calculations.
To overcome this, you can use another column to show the entered digits converted into a time. All you need to do is use a formula to do the conversions. For instance, if the time you entered was in cell A3, you could use the following formula in a different cell to do the conversion:
=(INT(A3/100)/24)+((A3 - (INT(A3/100)*100))/1440)
Format the cell that contains the above formula so it displays one of the various time formats, and you are all set.
(Full article and more at the source.)
This post may help you...
Formatting MM/DD/YYYY dates in textbox in VBA

Round to two decimal places

In the formula bar the data shows up as 69.849999999 and in the cell as 69.85. I am trying to get that number in the formula bar as 69.85. I tried Copy and Paste Values and almost everything else that I can think of. Even formatting the cell as a number with only two decimal places. Nothing is working.
Any ideas?
The following will radically change your data so use it with caution; possibly even on a backup copy until you are sure this is what you want.
If you have all of the numbers formatted the way you want (e.g. 0.00) then go into Excel Options (Alt+F,T). Choose Advanced from the list down the left and scroll the right pane down ¾ of the way to the When calculating this workbook section.
Click Set precision as displayed. Acknowledge the warning.
                
Remember to also click OK in the lower right to accept the option change and close Excel Options. All of the numeric values within your workbook will be rounded off to their displayed value of their number format. Note that numbers set to a General should not be affected.
Use at your own risk. I'm not saying this is a bad thing; just that you should be completely aware of the consequences before you commit large amounts of data to this option. See Change formula recalculation, iteration, or precision for more information.
Try:
=ROUND(A1,2)
then select, Copy, Paste Special, Values.
mrmcg,
=TEXT(A1,"0.00") is my preferred method here.
In hopes to be helpful it is a good idea to understand what you need to change to get the correct result. When you change the formatting (i.e. number, decimal, general) you are only changing the way the data appears, not the actual data.
You will need to use a formula like round, floor, text to change the actual data.
good luck and I hope that this is helpful!

Why does an if then statement turn into #VALUE! after closing and reopening the Excel file?

I have a somewhat large nested if then statement in a cell, which turns into #VALUE! after I save, close, and reopen the file. The if then statement is
=IF(H2="$0.10/$0.25",O2/0.25,IF(H2="$0.25/$0.50",O2/0.5,IF(H2="$0.50/$1",O2/1,IF(H2="$1/$1",O2/1,IF(H2="$1/$2",O2/2,IF(H2="$1/$3",O2/3,IF(H2="$2/$3",O2/3,IF(H2="$2/$5",O2/5,IF(H2="$3/$5",O2/5,IF(H2="$5/$5",O2/5,IF(H2="$5/$10",O2/10,IF(H2="$10/$20",O2/20,IF(H2="$10/$25",O2/25,IF(H2="$20/$40",O2/40,IF(H2="$25/$50",O2/50)))))))))))))))
To give some context, the value of H2 is different stakes in a poker game. For example, $1/$2 means that for every hand one person puts in $1 and the adjacent players puts in $2 before seeing their cards. The values $1/$2 are called the small and big blinds, respectively. A common way to track results is to convert all monetary values, with units $, into the units of big blind.
The statement gives no errors and outputs the correct value, in units of big blind, depending on the stakes, but after closing and reopening the cells containing the formula display #VALUE!.
I googled what the problem is and read that you can have a maximum of 64 nested functions, which is okay since I believe I only have 16. I also thought that there might be problem with cell formatting. For instance cell O2 has cell format currency, whereas the cell containing this nested if then statement has cell format general. I tested this idea on a separate sheet (same file) and it didn't cause the same error.
The version I have is 2011 running on a macbook.
Thanks for any help!
I couldn't reproduce this problem in windows excel 2010. My suggestion is to simplify the formula and try if the problem still occurs. You can do it this way:
=O2/MID(H2,FIND("$",H2,2)+1,LEN(H2))
Find the second "$", extract the text after it (big blind) and divide O2 by it.

Get Excel to display full values

I have an Excel spreadsheet with a range of values which are numbers that go to up 20 decimal places, unpivoted from another sheet using the trick from here.
The trouble is the cells are only displaying 10 digits so, for example, even though the value is 5.46827166811115 it is showing as 5.468271668.
I've tried setting the format to text but it still wants to treat it as a number, the number of decimal places varies so I can't use a fixed #.### format. The only way I can get it to show is to format the cells as text and to just select and then click in the entry box for each and every cell!
It then shows a warning that the number in the cell is formatted as text or preceded by an apostrophe but at least it's showing the full value.
I did find a VBA script that just did something stupidly simple like cell.Value = cell.Value for the selection which seemed to work but I can't find it anymore and I can't reproduce that now.
Surely there's an easier way to do this? It wouldn't matter so much but when I import this data through SSIS into a VARCHAR(MAX) it's getting the truncated values!
Pre-pend a single apostrophe ' to the data. In many cases, this is more effective than setting the cell format to text.
You could format the cell as text and the do an .AutoFit so the cell expands to show all the cell content, like this:
Columns("A:A").EntireColumn.AutoFit
that will expand the A:A cell so all its content is visible.
try formatting with #.000 instead of #.###, but if your problem is that Excel is dropping precision on you, you could try multiplying the value by 10^20, then dividing by 10^20 on the SQL side.
found more info:
here
looks like Excel is limited to 15 digits of precision, multiplying by 10^20 doesn't increase the precision, so you can treat it like text or split the remaining digits into another column and combine them back with SSIS or SQL.
Have you added the IMEX=1 to your connection string? That keeps SSIS from trying to figure out the data from the first few rows.
Also, what about using a decimal datatype instead of varchar(max)

Resources