I am trying to understand why this formula gives syntax error in Excel 2013:
=FIND({0,1,2,3,4,5,6,7,8,9};A1&"0123456789")
Worked well when looking for one number only:
=FIND({0};A1&"0123456789")
But having issue when trying to look for multiple value:
{0,1,2,3,4,5,6,7,8,9}
To get the position of the first digit in a string, use:
=MIN(FIND({"0","1","2","3","4","5","6","7","8","9"},A1&"0123456789"))
(which will return a 3 in the example below). To get the value of the first digit in a string use:
=MID(A1,MIN(FIND({"0","1","2","3","4","5","6","7","8","9"},A1&"0123456789")),1)
(your version of Excel may require ; rather than ,)
EDIT#1:
If you wish to parse a string and extract all the digits, use the array formula:
=--MID(SUMPRODUCT(--MID("01"&A1,SMALL((ROW($1:$300)-1)*ISNUMBER(-MID("01"&A1,ROW($1:$300),1)),ROW($1:$300))+1,1),10^(300-ROW($1:$300))),2,300)
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
Related
I am trying to match specific name (the names may be repeated several times) and to look up the name which has the lowest value in column D
Here's a snapshot to illustrate the issue
I would like for example to lookup the name Name1 and return the one who has the lowest value. In this case I need to return the row number 4 as this one has only 12 in value
I tried such a formula but didn't work for me
=MATCH("Name2",$A$2:$A$9,MATCH(MIN($D$2:$D$9),$D$2:$D$9,0))
You may use:
=MATCH(1,(A1:A9="Name1")*(D1:D9=MIN(IF(A1:A9="Name1",D1:D9))),0)
Note: It's an array entered formula using CtrlShiftEnter.
If you have Office 365, you can use the new XMatch function with an array returned by an IF statement. Like this formula, which assumes that the text "Name1" is in cell F1.
=XMATCH(0,IF(A1:A9=F1,D1:D9,NA()),1,1)
edit after comment: If you can't use Xmatch, then the data needs to be sorted by column D values from large to small. Then you can use Match() with a -1 as the last argument to look up the next value larger than 0. XMatch can do that with unsorted data, but Match needs sorted data for that.
Also, if you don't use Office 365, the formula needs to be confirmed with Ctrl + Shift + Enter, because it is an array formula. If you enter it in Office 365 Excel, that's not needed, but if people edit the workbook with an older version of Excel and edit the formula, they need to use Ctrl + Shift + Enter.
I am not an Excel expert and I need some help.
I have a list of different numbers and a reference number. I have a formula where it gives me the closest value of my number from this list
Example:
10
11
16
20
30
My reference number is 13.
I have found online a formula that gives me the closest number which in this case is the number 11.
=INDEX(list;MATCH(MIN(ABS(list-reference_number));ABS(list-reference_number);0))
But I want the result to be 16 (the next highest number).
I would like to know if this is possible and how can I achieve it.
Thanks in advance!
Since MATCH(refernce,list) will return the closest to 13. That means MATCH(refernce,list)+1 will return the result you looking for:
Formula in to use:
=INDEX(C1:C5,MATCH(13,C1:C5)+1)
Here's another Array formula for you to try (Ctrl+Shift+Enter):
=SUMPRODUCT(MIN(IF(A1:A5-B1>0,A1:A5)))
Provided column A contains the numbers, which can be unsortet by the way, you can get the closest higher number with:
{=MIN(IF($A:$A>B1,$A:$A,MAX($A:$A)+1))}
B1 contains the reference number (in your case 13).
Note: This is an array formular. You don't have to enter the curly braces. Instead paste the formular without { and } and press Ctrl + Shift + Enter to confirm your input.
I want to replace the comma separated letters in a cell with the numbers. I've used the=LOOKUP(A1,{"a","b","c","d","e"},{1,2,3,4,5}) function but it's only working for the single letter.
for example: my desired output:
a => 1
If you have Excel 2016+ with the TEXTJOIN function, you can use the array formula:
=TEXTJOIN(",",TRUE,CODE(UPPER(FILTERXML("<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>","//s")))-64)
Since this is an array formula, you need to "confirm" it by holding down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula as observed in the formula bar
Algorithm:
Convert comma-separated string to XML: "<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>"
Use FILTERXML to convert the XML to an array of strings
UPPER to make case insensitive
CODE(…) - 64 to convert to a series of numbers related to the letter)
TEXTJOIN to put the result together
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
Say, I got 2 words A1:ddC, A2:DDC
I want to convert these 2 words into a unique code so that so that i can do the Case Sensitive Vlookup.
So i tried, =Code(A1) & it returned 100, but if i tried =Code("dady") then it also returns 100. It is cos =Code() only pic the first char of the word.
I want to convert a word to a Unique Code (could be ASCII code or any form of unique code).
So how to do that without using VBA?
As this is a hash, it would be possible for some strings to end up with the same value, but it would be unlikely.
Note that the row function uses 1:255 to generate a list of numbers from 1 to 255 - change this number if your strings end up longer.
=A1&SUMPRODUCT(IF(IFERROR(CODE(MID(A1,ROW($1:$255),1)),0)>96,1,0),POWER(2,ROW($1:$255)))
This has to be entered as an array formula using CTRL+SHIFT+ENTER - you will see {} around the formula if you have successfully done that.
This will produce a decimal representation of the upper and lower case letters, and this is then appended to the word itself - this will guarantee uniqueness, as the only way to have a word and number match is to have the same word and case, which means it was a duplicate in the first place.
With this, ddC = ddC & 1*2 + 1*4 + 0*8 = ddC6
DDC = DDC & 0*2 + 0*4 + 0*6 = DDC0
ddC (ddC with a space after it) = ddc & 1*2 + 1*4 + 1*8 + 0*16 = ddC 6
*WARNING: * This is not a solution to the titled question
"How to convert a word to a Unique Code in Excel using Formula without using VBA?" but instead is a solution to what I believe is the underling problem as the original question states "so that i can do the Case Sensitive Vlookup." this is a solution acomplishing a Case Sensitive Vlookup, without the need to convert the values before doing so.
An alternative to converting all the values then doing a look up on the converted values, you could use the INDEX and MATCH functions in an array entered formula and directly look up the values:
=INDEX(A1:A14,MATCH(TRUE,EXACT(A1:A14,"ddC"),0))
This will return the value in A1:A14, at the same index of an exact (case-sensitive) match in A1:A14 to ddC you can VERY easily modify this into a look up of other columns.
Explanation:
Start with getting an array of all exact matches in your look up list to your look up value:
So if I enter this formula:
=EXACT(A1:A14,"ddC")
Then go into the formula bar and press F9 it will show me an array of true false values, relating to each cell in the range A1:A14 that are an Exact match to my expression "ddC":
now if we take this Boolean Array, and use the Match function to return the relative position of True in the array.
=MATCH(TRUE,EXACT(A1:A14,"ddC"),0)
But remember we need to enter this by pressing Ctrl + Shift + Enter because we need the EXACT(A1:A14,"ddC") portion of the formula to be returned as an array.
Now that we have the position of the True in the array, in this case 6 we can use that to retrieve the corresponding value in any column, as long as it is relational and that same size. So if we want to return the value of the exact match (although relatively useless in this situation, but will continue for demonstration) in the original look up column we just wrap the last formula up in an Index function:
=INDEX(A1:A14,MATCH(TRUE,EXACT(A1:A14,"ddC"),0))
But remember we need to enter this by pressing Ctrl + Shift + Enter because we need the EXACT(A1:A14,"ddC") portion of the formula to be returned as an array.
Now we can apply that same concept to a larger range for more useful look up function:
But remember we need to enter this by pressing Ctrl + Shift + Enter because we need the EXACT(A1:A14,"ddC") portion of the formula to be returned as an array.
Now notice in this last step I offered 2 formulas:
=INDEX(A1:B14,MATCH(TRUE,EXACT(A1:A14,D2),0),2)
And
=INDEX(B1:B14,MATCH(TRUE,EXACT(A1:A14,D2),0))
The first returns the value in the range A1:B14 in the Second column at the position of the exact match in A1:A14 to the value in D2 (in this case "dady")
The second returns the value in the range B1:B14 at the position of the exact match in A1:A14 to the value in D2 (in this case "dady")
Hopefully someone else can add more input but as far as I know the second might be better performing, as it has a smaller index range, and doesn't require going to the specified column, it is also shorter.
While the first to me is much easier to read, to some (more of a preference I think) because you know that your looking at a look up table that spans 2 columns and that you are returning the value in the second column.
*Notes: * I am note sure if this solution will be better in practice then converting the original values in the first place, seeing as how converting all the values once, then hard coding the converted values will require no additional formula or calculation (if formulas are afterwards replaced with values) once finished, while this method will recalculate, and also is array entered. But I feel in the case the asker is doing a single look up against a changing look up list (one that constantly requires all values are converted at all times using array formula) this option does allow you to remove the formula per word, with one single formula
all in all I hope this solves your original problem,
Cheers!!
if all your strings like the one you pointed above try something like this:
= CONCATENATE(Code(A1) , Code(Mid(A1,2,1)) , Code(Mid(A1,3,1)))
In order to account for capital letters you're going to end up with a VERY long formula, especially if you have long word entries. Without VBA I would approach it this way and set up the formula once to allow for the biggest word you anticipate, and then copy it around as needed.
Formula (to expand):
=CONCATENATE(IF(EXACT(A1,UPPER(A1))=TRUE,"b","s")&CODE(A1),IF(EXACT(A1,UPPER(A1))=TRUE,"b","s")&CODE(MID(A1,2,1)),IF(EXACT(A1,UPPER(A1))=TRUE,"b","s")&CODE(MID(A1,3,1)), . . . )
You can substitue the "b" and "s" with whatever you like. I was just using those for a case check for capital versus lowercase letters (b=big, s=small) and building that into your unique code.
In order to expand this, add additional cases to account for the length of the words you are using by adding this snippet JUST inside the last parenthesis and modifying the "3" in the MID() function to account for a word length of "4", "5", "6", etc.:
IF(EXACT(A1,UPPER(A1))=TRUE,"b","s")&CODE(MID(A1,3,1))
Painful, yes, but it should work.
Cheers.