I am using the formula:
=(INDEX($A$2:$A$300, MATCH(0, COUNTIF($B$1:B1, $A$2:$A$300), 0))
This takes a list of values from column A and reproduces it in column B to show each value only once, i.e. if a value is duplicated, it gets skipped.
For the most part it is working exactly as I hoped, however, some of the values in column A contain the wildcard character '?'.
Is it possible to get this formula to treat the '?' as just a standard character? Ideally I would like to include this rule in the formula itself rather than having to do a 'find and replace' with '~?'. Is this at all possible?
Many thanks
Change your formula to:
=(INDEX($A$2:$A$300,MATCH(0,COUNTIF($B$1:B1,SUBSTITUTE($A$2:$A$300,"?","~?")),0)))
confirmed with ctrl+shift+enter
This replaces the ? in the criteria array with ~? within your formula.
You need to "escape" those characters. This is done the same as when searching in Excel, by prepending them with the tilde character: ~
So this searches for the question mark:
=MATCH("~?",A1:A10,0)
Related
From this cell content in Excel MB_Dyt01_MB_Dyt11 I need to extract everything right of the second underscore "_" character.
I have tried with this formula
=RIGHT(E12;FIND("_";SUBSTITUTE(E12;"_";"_";2))+10)
Which returns yt01_MB_Dyt11 Not correct.
And with this fomula =RIGHT(E35;FIND("_";E35;4)-1)
Which returns 03_Fm09
Can you help me extract the text MB_Dyt11 from the above cell?
One option:
=MID(A1;FIND("~";SUBSTITUTE(A1;"_";"~";2))+1;999)
To add to BigBen's answer, you can use the combination of len() and right() instead of mid() so that the formula would work on text strings of any length
=RIGHT(A1,LEN(A1)-FIND("~",SUBSTITUTE(A1,"_","~",2)))
Using a MS Excel Formula (Not VBA), I would like to find the actual position/location of a specific word found within a String. If this is possible, I'd like to use a "Search and/or Replace" versus "Find or Substitute" function, as the text string is not an absolute by letter casing.
Cell A1 (Text String): "The dog ran behind the house and then jumped the fence."
Cell B1: (Target Keyword): Ran
Cell C1 (Position of Word): 3
Thanks in advance for your assistance.
The following would give you the word-index of the first word that contains your substring:
=SEARCH(B1,A1)-LEN(SUBSTITUTE(LEFT(A1,SEARCH(B1,A1))," ",""))+1
If you have access to FILTERXML you can retrieve it by throwing in some MATCH and this would return the word-index of an exact match:
=MATCH(B1,FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s"),0)
Note: The second formula needs to be entered through CtrlShiftEnter
As per #BigBen, you might run into troubled water if your string holds special characters like comma and the likes. In that case, you might want to throw in more nested SUBSTITUTE formulas to take care of that scenario.
If you need multiple matches, and you want it concatenated into a single cell, you'll need access to the TEXTJOIN function. To get all word-indexes of words that contain your substring:
=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH(B1,FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s"))),ROW(A1:INDEX(A:A,LEN(A1)-LEN(SUBSTITUTE(A1," ","")))),""))
To get all exact matches that hold your lookup value:
=TEXTJOIN(", ",TRUE,IF(FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s")=B1,ROW(A1:INDEX(A:A,LEN(A1)-LEN(SUBSTITUTE(A1," ","")))),""))
Note: Both formulas needs to be entered through CtrlShiftEnter
Suppose I have a row of cells that contain comma delimited strings like so:
I have figured out how to add the first character of each string using this formula:
=SUMPRODUCT(--(LEFT(C2:G2,SEARCH(",",C2:G2,1)-1)))
Now, I would like to extend the formula to the cell AA2, like so
=SUMPRODUCT(--(LEFT(C2:AA2,SEARCH(",",C2:AA2,1)-1)))
however, I cannot seem to get the it to ignore empty cells - it throws a #VALUE! error. I realize that I could simply update the formula each time I enter data in the subsequent cells, but that's not exactly efficient. I assume this throws an error because the SEARCH function returns a null value.
How might I get this to work?
You can try below modified formula:
=SUMPRODUCT(--(LEFT(C2:AA2&"0,",SEARCH(",",C2:AA2&"0,",1)-1)))
For right side you can use MID like below and check:
=SUMPRODUCT(--(MID(C2:AA2&".0",SEARCH(",",C2:AA2&",.0",1)+1,99)+0))
Your idea of searching for the comma is not needed if you only want to add the first character of each cell. Just grab the left-most single character.
Say we may have data from A1 to Z1 that may include some blank cells. Pick a cell and enter the array formula:
=SUM(IF(LEN(A1:Z1)>1,--LEFT(A1:Z1),0))
for example:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
How can I verify partial strings in cells across columns without having to look for an exact match?
I have a single spreadsheet with two columns that contain corresponding pairs of data in the form of text, or "strings". However, each corresponding pair almost matches except for a couple characters on the end. I need to make excel recognize the pairs despite the inexact string match, and return a "yes" or a "no" as to whether or not there a corresponding pair exists between the two columns. I want it to tell me "yes" or "no" in a single cell.
I do not want to delete characters from either column to make them match, they have to stay as they are.
My solution was that if I used an IF statement to determine whether A:A=B:B, all I would need to do is tell excel to also substitute the conflicting text characters with empty spaces, but that didn't work :( It returns #VALUE instead of a yes or no. I placed the function inside D1.
This is my formula:
=IF(SUBSTITUTE(A:A,"-Z","")*A:A=B:B,"Yes","No")
I think maybe I need a formula that will accomplish the following:
If a string with a length of up to 12 characters in a cell of column A matches another string in a cell of column B, return "true" in C2
I don't know what formula that would be. I would appreciate any help! Thanks in advance!
You can use this formula =IF(SUMPRODUCT(--(LEFT($A$2:$A$23,12)=LEFT(B2,12)))>0,"TRUE","FALSE"). It will first extract first 12 characters from strings in column A, then compare it to the first 12 characters in column B. Adjust range to your needs.
You can use VLOOKUP construct like below in cell C2 and then copy down:
=IF(ISNA(VLOOKUP(LEFT(A2,12)&"*",B:B,1,0)),"NO","YES")
I want to know how to identify a particular character in a column in Excel is used.
I am using this formula :
=IF((CODE(A1)=63),"YES","NO")
but only checks the first character and the second character and then not be checked.
Please guide me.
Try this:
={SUM(IF(ISERR(FIND(CHAR(63),A1:A999)),0,1))>0}
This is a matrix formula, enter without braces but terminate with Ctrl-Shift-Enter. Don't put this into column A.