I am looking to be able to process a large set of data and and find a set of predefined words in a string and return an alternate if found.. I have found i can do this individually with multiple FIND or SEARCH functions inside an IFS statement.. i want to include an OR in there though so i don't have to report as much... EG
Data:
Hello World
Hi World
Goodbye World
Bye World
I basically want to just return "Welcome" if either Hello or Hi are found in a cell
I know i can do it with htis: =IFS(ISNUMBER(SEARCH("Hello",[#Column1])),"Welcome",(ISNUMBER(SEARCH("Hi",[#Column1]))),"Welcome",TRUE,"")
But would like a shorter way, since in reality my data set is much larger. I tried this: =IF(ISNUMBER(FIND(OR([#Column1]="Hello",[#Column1]="HI"),"Welcome","")),"")
but just get a false response
also, want to keep it out of macros
You can do:
=IF( OR( ISNUMBER( SEARCH( {"Hello","Hi"}, [#Column1]) ) ), "Welcome", "" )
Related
I am trying to embed a SUBSTITUTE in my function, but I am not sure where to incorporate it. I am trying to extract just the text "Scrumactiviteiten" but in the source data sometimes a space will be in there. A sample:
Column A
1 Team xxxx 2018-17 Scrumactiviteiten 123 and then something
2 Team xxxx 2018-17 Scrum activiteiten 123 and then something
Column B (My formula)
1 Scrumactiviteiten
2 Scrum activiteiten
The function I used to extract it (ignore the "Balans" search please):
=IFERROR(IFERROR(IFERROR(MID(A1;SEARCH("Scrum activiteiten";A1;1);18);
MID(A1;SEARCH("Scrumactiviteiten";A1;1);17));MID(A1;SEARCH("Balans";A1;1);10));" ")
This works fine, but to remove the space I tried to embed a SUBSTITUTE where I use the mid search result as the old text and provide "Scrumactiviteiten" as the new text:
=IFERROR(IFERROR(IFERROR(SUBSTITUTE(A24;((MID(A24;SEARCH("Scrum activiteiten";A24;1);18)));"Scrumactiviteiten");MID(A24;SEARCH("Scrumactiviteiten";A24;1);17));MID(A24;SEARCH("Balans";A24;1);10));" ")
The result however is a copy of the full string. I also tried putting the substitute before the search but that would not work either. I am pretty new to Excel formula's and I think I messed up the order or just plain don't understand how I embed a SUBSTITUTE in the formula I created. Some explanation would be much appreciated on what I'm doing wrong! Thank you in advance,
Mark
The problem is you are not providing the correct arguments to the function, try this formula:
=IFERROR(IFERROR(IFERROR(SUBSTITUTE(((MID(A24;SEARCH("Scrum activiteiten";A24;1);18)));" ";"");MID(A24;SEARCH("Scrumactiviteiten";A24;1);17));MID(A24;SEARCH("Balans";A24;1);10));" ")
To use SUBSTITUTE you first provide the string in which you want to replace something, the next two arguments are the string you want replaced and the string you want to replace it with. So for example =SUBSTITUTE("Scrum activiteiten";" ";"") returns Scrumactiviteiten as the space " " is replaced with an empty string "".
Inside a complex Excel2010 formula, is there a way to embed a comment "within a section of the complex formula", so that certain sections (for example, IF-THEN statements) can be commented; allowing on-the-fly analysis of the formula?
I've read this post (How to add comment inside complex excel formula) which covers the basic function of adding comment text to the overall cell with "+N()", but I'm looking for a way to have multiple comments within the formula - similar to REM statements in a DOS batch file, or single-quote comments in VBA code.
Example - my formula (in a basic form):
=IF($C69="","cust is blank",
IF($AL69<>"#",
IF(MONTH($AL69)=$I$5,
"CM","err"),
IFERROR(IF(MONTH($AI69+INDEX('Check Grades'!$A$108:$D$112,MATCH($C69,'Check Grades'!$A$108:$A$112,0),4))=$I$5,
"NM (late)",
"NM (DGI)"
),
"no DGI"
)
)
)
I'd like to input comments for each IF section, if at all possible:
=IF($C69="","cust is blank", *If C69 is blank, then customer not listed*
IF($AL69<>"#", *If AL69 is NOT blank, then check for a valid month*
IF(MONTH($AL69)=$I$5,
"CM","err"),
IFERROR(IF(MONTH($AI69+INDEX('Check Grades'!$A$108:$D$112,MATCH($C69,'Check Grades'!$A$108:$A$112,0),4))=$I$5,
"NM (late)",
"NM (DGI)" *If AI69 plus a lookup value = I5, 'late' else 'on-time'*
),
"other"
)
)
)
...etcetera...
It looks like the +N() function works simply 'after' a formula. Yes, I can (& for the time being, will) split each section into different cells, but in the end, I'll need to combine them. During development of the complex formula, the comments can help me debug, and when all is done, I can paste them all into an external comment; but still, if this multi-comment-in-a-cell is possible, would like to use...
I would recommend spliting the complex formula into multiple parts/cells.
But if that is not an option, you can use the N() function in multiple locations, where the returned "0" value will not make a calculation/logical error.
I admit, I didn't study your formula to understand, if this is the case. I leave that privilege to you.
Here is an example of multiple N() functions not messing things up.
=N("Let me tell you a story,")+(SUM($B$2:$B$3)+N(" about a handful of comments,"))/COUNT($C$2:$C$5)+N(" that went to SO.")
The result is correct = 0+(20+0)/4 + 0 = 5.
I have no idea how to describe this but I'm so stuck and out of ideas so I will try.
I want to check if an item from one list is in another list that contains a wildcard
you can do the reversed thing with COUNTIF
example.
[LIST]
"Find ME Now",
"Find ME Later"
COUNTIF(LIST; "Find * Now")
This will result in a "match" because the wildcard is in the second argument.
But what i Want is the list to contain wildcards and still get a match
like
[LIST]
"Find * Now"
"Find * Later"
COUNTIF(LIST; "Find ME Now");
The above does now work but im trying to find something that does.
I made a VBA function that does what I want but that was running so slow because of a 1600 list * 10 list * 60 cells....
Edit:
I solved this problem with VBA and a global stored variable of results.
I think it might be worth sharing this even though #laxxen has a solution to the question.
You can set up a 'do-it-yourself' method of counting matches between the search string and the patterns. One formula I tried was the array formula
=SUM(--ISNUMBER(SEARCH($A$2:$A$5,B2)))
i.e. try the string in B2 with each of the wildcard patterns using SEARCH and count the number of positive results.
However I don't think this is quite right because SEARCH attempts a match at every position in the 'within' text, so if you want the case where it only matches starting at the beginning of the 'within' text, you need something like (another array formula)
=SUM(--IFERROR((SEARCH($A$2:$A$5,B2)=1),0))
This shows the results using the two formulae:-
I am trying to search for multiple items in a cell. If any of the terms I am looking for is present, I want cell D to display "Laptop", otherwise, display "Desktop". I can get the following to work, with just one term to search for:
=IFERROR(IF(SEARCH("blah",A2),"Laptop",""),"Desktop")
But I want to search for the presence of blah, blah2, and blah3. I don't know how to get Excel to search for any of the following terms. (Not all of them mind you, just any of the following.
I did see that there is an or option for the logic.
=OR(first condition, second condition, …, etc.)
I am not sure how to get these two to work together. Any thoughts on how to get them to display "Laptop" if any of the words are present?
This should work:
=IF(SUM(COUNTIF(A2,"*" &{"blah1";"blah2";"blah3"}& "*"))>0,"laptop","desktop")
You could use the combination of OR, IFERROR and SEARCH as you suggest, but I think the simpler construct would be ...
=IF(AND(ISERROR(SEARCH("value1",A2)),ISERROR(SEARCH("value2",A2))),"Desktop","Laptop")
I'm using the MCONCAT formula (with success & help from others) to create a single string of multiple attachment names to associate them with a single record # (I am converting data from a legacy system to another by way of flat files and a data loader).
An example: | Contract 1 | filename.pdf, filename2.doc |
However, when the first load was run, records that had a comma in the name error-ed out because the data loader is viewing the comma as the break between files. After some research, we decided to use '#' as the delimiter between multiple files in a cell. Now I am stuck trying to substitute the comma delimiters in my MCONCAT formula with '#' and have been fruitless so far.
Here is the code as I am using it now:
=SUBSTITUTE(MCONCAT(IF($A$2:$A$11133=$D2,", "&$B$2:$B$11133,"")),", ","",1)
Is this possible to do? If so, how & maybe (if not asking to much) a short explanation so I can fully understand.
An example of the hopeful solution: | Contract 1 | filename.pdf # filename2.doc |
Depending on the complexity of the filenames with commas in, you might be able to do what you want simply using the Find & Select / Replace feature of excel.
Please use a copy of your workbook if you try anything suggested.
If your separator is always [list item][comma][space][list item] and none of your [list item(s)] contain [comma][space] then using a "find what" term of ", " (note the space!) and "replace with" term of "# ", Using [at][space] instead of [space][at][space] is probably better, and selecting the column containing the list should fix your problem.
A VBA solution is possible but it would probably be more effort than its worth. You might need to write lots of rules telling it how to split and join stuff, and end up with it still not being perfect.
While doing it manually might not be a fun idea, you could use something like "text to columns" to split your list then look over the results and fix the errors then re-join using your new delimiter.