Is it possible to format numbers in scientific notation as exponents with the base 10 rather than E in Excel?
For example, Excel converts 0.00123 to 1.23E3, but I would like the format
This is not possible by using the standard number formatting in Excel.
You could of course convert your number to a text string with =TEXT(A1;"0.00E+00"), and then you can convert this text string to a new text string in the format that you want. It gets a bit tricky with the superscripts, as you have to display these with the UNICHAR function (this function is available since Excel 2013).
The Unicode values to use with the function are the following (from superscript 0 till 9):
8304,185,178,179,8308,8309,8310,8311,8312,8313
So superscript 50 would be =UNICHAR(8309)&UNICHAR(8304)
You can create elsewhere in your workbook a named range with this values, so the conversion would be easy with an INDEX.
Actually, I would create two ranges, one for the first digit of the exponent (where you don't have a 0, but an empty string, as you don't want to display 10^03 but 10^3), and the second one for the second digit of the exponent (where you keep the 0).
To summarize:
Convert the number to a text sting with =TEXT(A1;"0.00E+00")
Replace the "E" with "x"
Replace the "+" with "10"
If number is negative, add a -
Replace the two last characters with the corresponding superscript (convert back to number with NUMBERVALUE() and then use INDEX() to get the Unicode value to feed into the UNICHAR function.
So for the last digit, the formula is (the named range for the Unicode values is EXPO1 and EXPO2 in my case):
=UNICHAR(INDEX(EXPO2;1;NUMBERVALUE(RIGHT(A1;1))+1))
For the first digit of the exponent (i.e. the one but last character of the text string), use this formula to convert into superscript:
=UNICHAR(INDEX(EXPO1;1;NUMBERVALUE(LEFT(RIGHT(A1;2);1)+1)))
I am a bit lazy here, I could use MID as well instead of the LEFT/RIGHT combination. And please note that the named range is now EXPO1, where the first value is the Unicode value of the empty string (8203).
The entire formula is:
=LEFT(TEXT(A1;"0.00E+00");4)&
"x10"&
UNICHAR(INDEX(EXPO1;1;NUMBERVALUE(LEFT(RIGHT(TEXT(A1;"0.00E+00");2);1)+1)))&
UNICHAR(INDEX(EXPO2;1;NUMBERVALUE(RIGHT(TEXT(A1;"0.00E+00");1))+1))
with EXPO1 and EXPO2 the named ranges as explained above.
To make the formula completely self-sustained, you can hardcode these into the formula, so this becomes then :
=LEFT(TEXT(A1;"0.00E+00");4)&
"x10"&
UNICHAR(INDEX({8203,185,178,179,8308,8309,8310,8311,8312,8313};1;NUMBERVALUE(LEFT(RIGHT(TEXT(A1;"0.00E+00");2);1)+1)))&
UNICHAR(INDEX({8304,185,178,179,8308,8309,8310,8311,8312,8313};1;NUMBERVALUE(RIGHT(TEXT(A1;"0.00E+00");1))+1))
Finally, please note that the formula is dependent on how you convert the number into text. Per OP initial question, I used 2 digits precision after the comma ("0.00E+00"). If you want to display more, you have to extract more than 4 characters with the first LEFT formula in my example.
You may want to use VBA (Visual Basic for Applications).
I created a VBA macro (https://github.com/hisakatha/exp2superscript) to convert exponents into superscripts via text formatting function.
This macro can be imported in the Excel's Visual Basic for Applications editor and registered in Excel Add-ins, and then the macro can be called in Excel.
Briefly, the macro replaces "E" with "×10" using the VBA Replace function and format the exponent part of numbers as superscripts using an assignment:
<cell>.Characters(Start:=<index of the exponent>).Font.Superscript = True
Related
Example:
I am using the formula:
=IMDIV(F3,0.7)
f3 value = 37.44, so the result on the formula cell = 53.9948890...
I need to turn the 53.9948890... into a dollar value, so I want to show it like $53.99
AT THE END I JUST WANT THE DOLLAR VALUE WITHOUT ANY FORMULAS.
How can I format the results of the formula into dollar value?
I tried to highlight the cells and change the formatting but it DIDN'T WORK.
I tried to copy and paste just the numerical values and then formatting the cells, and it DIDN'T WORK.
If I type the number and then I try formatting the cell, then IT WORKS, but then I need to do it manually for hundreds of lines..
You can use DOLLAR but this returns text again which means you cannot input this into mathematical comparisons/functions as is.
=DOLLAR(IMDIV(F3,0.7))
I would recommend using ROUND instead to convert your output to be numeric and then just format the column as currency. Then you have numeric outputs that you can actually feed into functions or compare
=ROUND(IMDIV(F3,0.7),2)
The real question is why are you using IMDIV in the first place? As you have discovered, that method will require some downstream work to format to number/currency. Since you are just supplying real numbers, you don't really use the 'special sauce' that is added to the IMDIV function. You are just taking extra steps to do a standard division.
i.e. (37.44 + 0i) / (0.7 + 0i) = 37.44/0.7 so why not just use F3/.7?
As you can see in below photo, both outputs return the same number. The only difference is the IMDIV function returns this value as string which has to be converted before later use.
I have a user-supplied field which stores a numeric GTIN as text. I validate that the field is 7 or 11 characters in the next cell.
It's easy enough to add a formula such as =OR(LEN(A1)=7,LEN(A1)=11), but there are cases where the user pastes from another excel document, for instance, a number with a custom format of 11 0's. The cell appears to contain 11 characters with a few leading zeros, but the LEN formula sees fewer characters (ex. the cell may display 00123456789, but LEN(A1) = 9). I'm at a loss as to how I can control for this.
Without macros, how can I find the length of this displayed value?
I appreciate any assistance!
A quick user defined function (aka UDF) can replace the standard LEN worksheet function.
function displayLEN(rng as range)
displayLEN = len(rng(1).text)
end function
Put this into a standard module code sheet. Use just like the worksheet's LEN function; e.g. =displayLEN(A1)
I have a match function that I could not get working. I boiled it down to the point that it can't find the appropriate match since the values are not the same, apparently.
I have the value 21337 in cell D59. In cell S59 I have the function: Right($d59;5), which displays 21337. However when I enter in a cell: =D59=S59 i get the return FALSE.
I use the Right() function because cells in column D contain concatenated values, where the last 5 values are of importance. For example D60 contains 21337 - 21448, where 21448 is the value I want to match.
Anyone has a clue on what might be the problem?
With no formatting you'll see that 21337 is right aligned - showing this is a number and treated as a number by Excel.
On the other hand Right($d59;5) will show the number left aligned, indicating that the returned value is being treated as text by Excel.
If you try Right($d59;5)*1 Excel will implicitly convert the value back to a number (due to the calculation performed) and both values will be equal.
To be explicit about the conversion, as Brian has pointed out, use VALUE(Right($d59;5)).
If you use "Formula" > "Evaluate Formula", does it show the penultimate Evaluation as21337="21337"
The LEFT(..) function will convert the number to a string, and the string and the number will not equate. Try either =TEXT(D59,"#")=S59 or =D59=N(Left(S59)) to convert in your comparison, or change the code in S59 to =N(Right($D59,5)) to make S59 show a number
(The N(..) function converts a string to a number, returns 0 if Not A Number)
I have an excel formula that is producing a lot of decimal places and I cannot reduce them using the format cell -> numbers -> decimal places options. Here is the formula.
Cell named V01_MIN
V01_MIN =MIN(6:6)
Has a value of 2
Cell named V01_MAX
V01_MAX =MAX(6:6)
Has a value of 1800
Cell named V01_A
V01_A =1-V01_MIN*V01_B
Has a value of 0.889877642
Cell named V01_B
V01_B =99/(V01_MAX-V01_MIN)
Has a value of 0.055061179
X6=723
X7=V01_A+V01_B*X6 (value of 40.69911012)
X8=1
X9=X7*X8 (value of 40.69911012)
X10=1
X11=X9*X10 (value of 40.69911012)
X13==CONCATENATE(X12,", ",X11)
The final results of X13 are:
V01, 1162, 40.6991101223582
I want them to be:
V01, 1162, 40.7
I'm trying to figure out how to make this happen. I've already tried changing the cell formatting on all of these cells (including the final cell) to one decimal palce and that didn't work.
Cell formatting and the actual number in the cell are two different things.
The cell formatting merely changes how the number is shown to you in the cell.
The actual number in the cell will still keep all precision of the number.
If you wish to have the last number rounded, consider this:
X13=CONCATENATE(X12,", ",ROUND(X11,1))
This will round the result in X11 to 1 decimal place before concatenating.
By concatenating you are changing your data to text instead of a number and the number formats won't effect it. Generally you have two options
Either round within you concatenate function
X13==CONCATENATE(X12,", ",roound(X11,1))
or change it back to a number (easiest way is multiply by 1): Note this won't work in your case since you are joining text strings and variables but is useful to be aware of.
X13==CONCATENATE(X12,", ",X11)*1
and then you can format based on decimal places.
I have a spreadsheet used to verify a long list of 8-digit hexadecimal numbers for duplicates.
It has two columns - one for the hexadecimal values and another where the following formula is used to check for duplicates (given that this second column is column B):
=COUNTIF($B:$B, B1)
This has worked fine for most numbers except for these values:
69000700 and 690007E2.
The first column is formatted as text, however it seems that the COUNTIF function is doing some kind of unwanted implicit cast of my hex value, and taking the second hex value as an exponent (which would make it the same as the first value).
It also doesn't seem to matter what format my hex column is - the COUNTIF function always interprets these values as numbers and therefore they appear as duplicates.
Is there a way to ensure the COUNTIF function takes these cell values as string parameters without doing an implicit cast?
Maybe it's feasible to add an extra column with a formula
=CHAR(34) & B1 & CHAR(34)
copied down.
The formula encloses the text into quotes, and "690007E2" will no longer be interpreted as "69000700" (Excel 2003).