Formula to print 'X' if comma separated string value = '<value>' - excel

I am trying to have Excel print 'X" in a table column based on if a specific value is found in a comma separated string given to me from a Microsoft Form.
I removed the characters I don't want, and now my comma separated string is just that, comma separated only.
I have tried a formula where if I search the string and it finds the value I am looking for, it returns to the corresponding table column with 'X'.
Original Output from Microsoft Forms:
["ViewPoint","B2W Estimate","Nektar Equipdata"]
I have used this formula to strip characters that I don't want/need.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Applications[Applications], "[", ""),"""",""),",",", "),"]","")
This is the formula I am trying to use to get the corresponding column to input what I want.
=IF([Column7]=(SEARCH("ViewPoint",[Column7])),"X","")
Here is the expected and the actual result :
Expected Result: "X"
Actual Result: "#NAME?"

This should work, if i understand your question correctly.
=IF(ISNUMBER(SEARCH($B$1,A4)),"X","-")
If you want the total number of occurances in the column, you need this ARRAY Formuly CTRL + SHIFT + ENTER
=SUM(ISNUMBER(SEARCH($B$1;A4:A7))*1)

I believe you get he #NAME? result if the searched item doesn't contain the string of interest, because it is checking "Does myString = #ERR ?"
In addition to the other answer, you could also try:
IF(ISERROR(SEARCH(...)),"X","-")

Related

How to extract a string from 2 strings in Excel counting from the second string instead from the default left side

Here's a string:
Sample text here, EXTRACTTHIS(), and ignore the rest.
I want EXTRACTTHIS() to be extracted, so I used this simple formula:
=MID(LEFT(A5,FIND("()",A5)+1),FIND(" ",A5)+1,LEN(A5))
However I got this:
text here, EXTRACTTHIS()
Of course I can just mod it to be =MID(LEFT(A6,FIND("()",A6)+1),FIND(" ",A6)+10,LEN(A6)) to get EXTRACTTHIS().
But I want this formula to work with the whole column such as the following example:
I give you the next sample: WHAT_IF_THE_STRING_LENGTH_IS_DIFFERENT(), what to do?
The problem is that Excel counts from the left side of the parent string. I want Excel to count the 1st substring ' ' from the right side of the 2nd substring which is (). Is it doable?
In your examples, it appears you want to extract the substring that ends with ().
If that is not what you mean, please be more specific.
Try: =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("()",A1)+1)," ",REPT(" ",99)),99))
Find the location of the (): FIND("()",A1)
Extract the portion of the string up to and including the ()
LEFT(A1, ... +1) => Sample text here, EXTRACTTHIS()
Then extract the last space separated substring from that
TRIM(RIGHT(SUBSTITUTE(... , " ",REPT(" ",99)),99))

How do I remove a specific value from a string of comma separated values?

I have two columns. Column A with a single value and Column B with a string of comma-separated values.
I want to find the value in Column A in the string of values in Column B and remove it. Leaving the remainder of the values separated by the commas.
For example:
The SUBSTITUTE formula ive been playing with is =SUBSTITUTE(B2,A2," ")
One issue that I'm running into is some of the values have the "/" character in them which I wish to keep.
Example:
Column A
FC0201F1I
Column B
FC0201F1I,FC0201F1I/FC0201F2I,FC0201F2I
SUBSTITUTE output ruins the Value:
, /FC0201F2I,FC0201F2I
The output I'm looking for:
FC0201F1I/FC0201F2I,FC0201F2I
Any Excel Formula combination or VBA Code to help me in this mystery would be greatly appreciated. I feel the solution is so simple and staring at me in the face but I am unable to see it.
Thank you for all your help!
Add commas to the beginning and end to both strings inside the SUBSTITUTE then use spaces and trim to remove the , if they are added to the front or back and not replaced:
=SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(","&B2&",",","&A2&",",""),","," "))," ",",")
Alternatively, this is possible through some xpath in FILTERXML():
Formula in C1:
=TEXTJOIN(",",,FILTERXML("<t>"&A1&"<s>"&SUBSTITUTE(B1,",","</s><s>")&"</s></t>","//s[.!=../text()]"))
Do 2 substitutions, 1 for the search term followed by a column and 1 for the search term preceded by a comma.
=SUBSTITUTE(SUBSTITUTE(B2,","&A2, ""), B2&",","")

Is there a way to check if charachters in a string is contained in an array of charachter - NO VBA

I have a long string in excel. I need to check if every char of the string match an array of char.
For example:
Array of allowed char: "i a m n o t I t e r s d *space*" --> CHECK OK
"I am not interested" --> check ok
"I am not very interested" --> check failed : v and y non allowed
I have tried with find or match but they just look for the first occureence,....
For a case-sensitive approach, if you have the CONCAT function, you can use the following:
(For case-insensitive, replace FIND with SEARCH)
=IF(OR(ISERR(FIND(MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1),1)),1),CONCAT(" ",AllowedChars)))),"check failed", "check ok")
If you do not have the CONCAT function, replace it, in the formula, with a simple string of the allowed characters:
=IF(OR(ISERR(FIND(MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1),1)),1)," iamnotItersd"))),"check failed", "check ok")
and note that some earlier versions of Excel will require that you confirm this array formula by holding down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.
the MID(… function creates an array of the individual characters in the test string
FIND then does a case-sensitive FIND of all the characters in test string against the characters in AllowedChars
FIND will return a #VALUE! error if the character is not found.
OR(ISERR(… will return TRUE if there are any failures to match.
Edit further explanation:
ISERR(… will return an array of Booleans {FALSE,FALSE,FALSE,FALSE,TRUE, … } depending on whether each FIND is returning a number of the #VALUE! error
OR evaluates that array and returns TRUE if there is any error at all.
Where AllowedChars refers to the range storing the allowed characters.
CONCAT ignores empty cells in a range, so we have to add the space as one of the arguments.
With a UNIQUE list of acceptable characters in a range(I used D1:D10) one can compare the sum of the difference of removing each character and the length of the string without spaces:
=SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(A1,$D$1:$D$10,"")))+1 = LEN(SUBSTITUTE(A1," ",""))
This formula ignores case and the list must be a unique list of allowed characters. I and i are the same as Excel sees it and only one can be in the list.

match the number from comma separated value and count

I have a comma separated value in A2 and same numbers in different cells B1, C1, D1.... I want to match them from comma separated value and find out the count in B2, C2, D2. Please see the image attached you will get the context.
Can we achieve this by formula or macro in excel?
Tried formula:
=LEN(TRIM($A$2))-LEN(SUBSTITUTE(TRIM($A$2),C1,","""))
Also, I have two data sets where I will be using this formula to find out the count of number from comma-separated value and based on count I want the repeated ones to come in a different cell please refer the image for better understanding.
Probably not the best solution but get the job done. Please note it is case-sensitive and please make sure to press Ctrl+Shift+Enter upon finishing this formula.
{=SUM(--(EXACT("!"&TRIM(MID(SUBSTITUTE($A2,",",REPT(" ",100)),(ROW(INDIRECT("1:"&LEN($A2)))-1)*100+1,100)),"!"&B1)))}
You can replace ! in the above formula with a unique symbol that will never appear in the text string to be safer.
The logic is to SUBSTITUTE the comma , with and long string of blanks, then use MID to find each value in the text string and return the result as an array, then use EXACT to match each value in the array with the look up value and return a new array of TRUE and FALSE, then SUM up all TRUE which will give the count of the look up value.
UPDATE #2
As requested by OP, here is one way of solving the second query which is to match the same value with the same occurrence from two text strings separated by comma ,.
The formula in Cell C2 is from the original solution which is used to find the occurrence of a given value in a text string;
The formula for Range C6:K6 is an array formula as shown below. I used a helper row to layout the matching values, and excluding the one that has 0 count for both data set;
{=IFERROR(INDEX($C$1:$K$1,,AGGREGATE(15,7,COLUMN(INDIRECT("1:"&COLUMNS($C$1:$K$1)))/($C$2:$K$2=$C$3:$K$3)/($C$2:$K$2>0),COLUMN()-2))&",","")}
The formula in Cell L8 is concatenating all values from Range C6:K6 and remove the last comma , from the final text string:
=LEFT(CONCATENATE(C6,D6,E6,F6,G6,H6,I6,J6,K6),LEN(CONCATENATE(C6,D6,E6,F6,G6,H6,I6,J6,K6))-1)
The following worked for me, give it a try:
Formula in B2:
=(LEN(","&SUBSTITUTE($A$2,",",",,")&",")-LEN(SUBSTITUTE(","&SUBSTITUTE($A$2,",",",,")&",",","&B$1&",","")))/LEN(","&B$1&",")
Drag right...
A simpler way of doing it is to simply calculate the difference in the length of the string minus the length of the string when replacing the value searched by nothing and dividing by the length of the string searched
The formula would be:
=(LEN($A$1)+1-LEN(SUBSTITUTE($A$1&",",B1&",","")))/LEN(B1&",")
There is a much simpler solution:
=COUNTIF(SPLIT($A$2, ","), B1)

MS Excel: remove number of characters after a specific character in a string

I have a column with values like
WI60P-14E64F5167E6-01138
or
WI60-34D03E185267-01051
etc....
i need to find the first occurrence of - till the second occurrence of - and remove the resulting character.
I am using this function =MID(A1,FIND("-",A1),13) which returns me -34D03E185267 or -14E64F5167E6 from the above strings.
But I want the output like WI60P-01138 or WI60-01051
Can anyone help me?
Assuming that the length of text between the two hyphens never varies, you can use your existing function, along with SUBSTITUTE to get the desired string, like so:
=SUBSTITUTE(A1,MID(A1,FIND("-",A1),13),"")
Alternately, you can use FIND to get the hyphen positions and again use SUBSTITUTE to get the replaced string, like so:
=SUBSTITUTE(A1,MID(A1,FIND("-",A1),FIND("-",A1,FIND("-",A1)+1)-FIND("-",A1)),"")
Notice that one of the FIND expressions takes 3 parameters - by passing FIND("-",A1) + 1 as the third parameter, we get the second occurence of '-' within the cell.
This will work for any position of the two hyphens:
=CONCATENATE(MID(A1;FIND("-";A1)+1;FIND("-";A1;FIND("-";A1)+1)-FIND("-";A1)-1))
Solution using multiple cells as support (with dynamic length of the string):
Put this in cell B1 to obtain the first part of the code:
=MID(A1,1,FIND("-",A1)-1)
Put this in cell C1 to obtain the last part of the code:
=MID(A1,FIND("-",A1)+1,LEN(A1))
Put this in cell D1 to concatenate both and get your result:
=concat(B1,C1)
Solution in a single cell (with dynamic length of the string)
Put this in cell B1 to get the same result as above :
=concat(MID(A1,1,FIND("-",A1)-1),MID(MID(A1,FIND("-",A1)+1,LEN(A1)),FIND("-",MID(A1,FIND("-",A1)+1,LEN(A1))),LEN(MID(A1,FIND("-",A1)+1,LEN(A1)))))

Resources