Extract multiple strings from the same cell using Formulas - excel

I have contents of one excel cell as: for example
Bananas_05/05/2019
Oranges_07/06/2019
Oranges_08/05/2019
Apples_10/12/2018
Oranges_08/03/2019
I want, using formulas only (no VBA) to extract all the dates next to "Oranges_" So I want the output to be:
07/06/2019
08/05/2019
08/03/2019
My current formula can extract only 1 of them, not all
I have no idea what I can try
This is what I have:
DATEVALUE(MID(D20,FIND("Oranges_",D20)+LEN("Oranges_")+1,10))

This is only possible if one has TEXTJOIN() which was introduced with OFFICE 365 Excel.
If one has TEXTJOIN() then this array form will iterate each line and test then concatenate the dates.
=TEXTJOIN(CHAR(10),TRUE,IF(ISNUMBER(SEARCH("Oranges_",TRIM(MID(SUBSTITUTE(A1,CHAR(10),REPT(" ",999)),ROW($XFD$1:INDEX($XFD:$XFD,LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1))*999+1,999)))),SUBSTITUTE(TRIM(MID(SUBSTITUTE(A1,CHAR(10),REPT(" ",999)),ROW($XFD$1:INDEX($XFD:$XFD,LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1))*999+1,999)),"Oranges_",""),""))
Being an Array Formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

Related

Add value to different integers in same cell in MS Excel

I have a typical book index in a spreadsheet that goes like this:
I need Excel to recognize the different integers in the same cell and add a constant each one of them.
Let's say the constant is 5
The result should be like this:
I couldn't get excel to recognize the different values in a cell.
My two cents, assuming Excel ms365:
Formula in B1:
=BYROW(A1:A3,LAMBDA(a,LET(X,TEXTSPLIT(a,", "),TEXTJOIN(", ",,IFERROR(X+C1,X)))))
Or, if no access to TEXTSPLIT(), then use:
=BYROW(A1:A3,LAMBDA(a,LET(X,FILTERXML("<t><s>"&SUBSTITUTE(a,",","</s><s>")&"</s></t>","//s"),TEXTJOIN(", ",,IFERROR(X+C1,X)))))
Or, if no access to BYROW(), you'd have to drag the following:
=LET(X,FILTERXML("<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>","//s"),TEXTJOIN(", ",,IFERROR(X+C$1,X)))
Not sure if this could be done smoothly and without using long and complex formulas.
Why don't you try to split the cell into multiple columns (Data > Data Tools > Text To Columns > Delimited and select Comma as delimiter). Once you have all different values is separate columns, it would be easy to apply formulas and add the constant.
After that, you could use CONCATENATE formula to merge texts and numbers back to single value in a single column.
Hope this helps.
I would separate the text and each value into separate cells, then use & to combine into the format you want, something like so:
=A1&", "&B1+G1&", "&C1+G1&", "&D1+G1
where A1 contains "Trauma" and B1 contains 15, C1 contains 17 and D1 contains 25. G1 holds the constant 5.
See
This is what I have tried,
Formula Applicable To Only O365 Beta Channel (Insiders).
• Formula used in cell B1
=TEXTJOIN(", ",,TEXTBEFORE(A1,", ",1),TEXTSPLIT(TEXTAFTER(A1,", ",1),", ")+5)
Or, if you are not using the above Excel Version, but using either Excel 2019, 2021 or Regular O365, then,
• Formula used in cell B1
=TEXTJOIN(", ",,LEFT(A1,FIND(",",A1)-1),IFERROR(
FILTERXML("<a><b>"&SUBSTITUTE(A1,", ","</b><b>")&"</b></a>","//b")+5,""))
Edit
One improvised approach:
=TEXTJOIN(", ",,TEXTBEFORE(A1,", ",1),IFERROR(TEXTSPLIT(A1,", ")+5,""))
You can also accomplish this task quite easily with Power Query.

Return multiple comma separate values via lookup in Google sheets / Excel

I am looking for some help in creating a query in Google sheets that will look up a list of words (C2:C17) and see if those words appear in paragraphs of text in cells A2:A10. The result should see a comma separated list of words in column E and I'd like to be able to drag the query down through E2, E3, E4, etc.
Whilst it's ideal to do this in Googlesheets, i'd be happy with an Excel formula too.
Below is a sample spreadsheet to illustrate what I am trying to achieve.
Samlple sheet:
https://docs.google.com/spreadsheets/d/1DmafyX6xj7QRut5L2aTRMLGx0dhE-LKIgAcSpxE4OHs/edit?usp=sharing
In excel if one has TEXTJOIN in their version:
=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH($C$2:$C$18,A2)),$C$2:$C$18,""))
Depending on version this may need to be entered with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
I think(untested) this for GoogleSheets:
=ARRAYFORMULA(TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH($C$2:$C$18,A2)),$C$2:$C$18,"")))

Excel formula in sorting delimited numbers in a single cell

Im new in excel formulas. I need an excel formula that can sort delimited numbers in a single cell.
Note: I have different lengths of values per cell.
I.g.
349|2|4|11|1|2
Outcome:
1|2|2|4|11|349
Im thinking of reverse concatenating it first then sort it then concatenate it again. But i can't figure it out how to make a working formula for that. Hope someone can help me. Thanks.
This formula solution worked in cell contains numeric value only.
The formula using Textjoin and Filterxml function of which Textjoin available in Office 365 and Excel 2019, and Filterxml available in Excel 2013 and later Excel version
Assume your data housed in A1
In B1, enter array formula (Confirm by pressing Shift + Ctrl + Enter) :
=TEXTJOIN("|",1,IFERROR(1/(1/SMALL(FILTERXML("<a><b>"&SUBSTITUTE(A1,"|","</b><b>")&"</b></a>","//b"),ROW($1:$99))),""))

Index-Small formula keeps repeating

The excel formula that I'm using appears to be repeating the same results upon condition of only one value on my conditional formatting drop down list. In this case, it repeats the results only for "Pacira Biosciences". How can I fix it to stop repeating the same results just like the other items on the drop down list?
The formula is this:
=IFERROR(INDEX(RAW!$D$2:$D$279,SMALL(IF(RAW!$B$2:$B$279=$C$5,ROW(RAW!$D$2:$D$279)-1,10^10),ROWS($A$1:A1))),"")
Excel File can be seen/downloaded here on Google Drive:
https://drive.google.com/file/d/1UYw1ZX941yr2gVY0DOBd_YEGI1d9jmPG/view?usp=sharing
Use this array formula:
=IFERROR(INDEX(RAW!$D$2:$D$279,SMALL(IF(((RAW!$B$2:$B$279=$C$5)*(IFERROR(MATCH(RAW!$D$2:$D$279,IF(RAW!$B$2:$B$279=$C$5,RAW!$D$2:$D$279),0)=ROW(RAW!$D$2:$D$279)-1,FALSE))),(ROW(RAW!$B$2:$B$279)-1)),ROW(1:1))),"")
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode
If in the future you upgrade to OFFICE 365 then it gets much simpler:
=UNIQUE(FILTER(RAW!$D$2:$D$279,RAW!$B$2:$B$279=$C$5))

Search for multiple values on two rows on multiple columns Excel

I have the next table (the table has this format),
Excel table
I wanto to search for all the 9's on the row 3 and obtain all the dates on columns A to T for each 9.
In my example the result should be,
29-06-2016
30-06-2016
01-07-2016
02-07-2016
04-07-2016
05-07-2016
06-07-2016
07-07-2016
08-07-2016
09-07-2016
I've tried the index/small formula but the result is only the first date.
Can anyone help me?
The array formula in the first cell:
=INDEX($A$1:$T$1,SMALL(IF($A$3:$T$3=$V$3,COLUMN($A$3:$T$3)),ROW(1:1)))
Being an Array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then excel will put {} around the formula.

Resources