Excel : How to apply a criterion to each cell in an array? - excel

So in the example above, I would like to extract all cells that contain "A" as the first letter(and length=9, though it does not matter). Now I am able to run the function for one cell, but I want to run it as an array formula so that I do not have to drag down 1000 cells every time. Below is my code:
=IFERROR(INDEX($A$1:$A$3, IF(AND(LEFT(A2,1)="A", LEN(A2)=9), ROW($A$1:$A$3),"")),"")
The problem here is that when I enter the code with "Ctrl + Shift + Enter", the criteria would be only confined to A2, which is the cell address I manually entered. Is there anyway to check for every single cell without having to drag down WITHOUT USING VBA? I know using VBA would make it a lot easier, but I just want to understand the basics of Excel further.

Try,
=iferror(index(a:a, aggregate(15, 7, row(a:a)/(left(a$1:index(a:a, match("zzz", a:a)))="a"), row(1:1))), text(,))
'with 9 length criteria
=iferror(index(a:a, aggregate(15, 7, row(a:a)/((left(a$1:index(a:a, match("zzz", a:a)))="a")*(len(a$1:index(a:a, match("zzz", a:a)))=9)), row(1:1))), text(,))
Fill down as necessary.
If you only want the single left-most character from a string of text, you do not have to supply a 1; you can omit the number of characters argument.

Related

Question about inputting formulas in Excel

I am creating a worksheet for Simpson's Rule and I would like to make it flexible for different equations.
So I have a cell just for the endpoints, step size and formula, and then a table for my calculations.
I know I can just directly input the formula that I want into the table. But is there a way to do it such that when I change the formula cell, the value will change as well?
For example:
So if I changed my f(x) cell to x, it should give me (0, 1, ..., 10) under f(x) for the table.
Additionally, is there a way to stop autofill the multiplier column? I know that the first and last entries should be 1, and the middle should be the sequence of (4, 2, 4, 2, ..., 4). Is there a way to automate this?
You can evaluate a string using Excels EVALUATE function. Check out this SO post here.
It is still (sort of) possible to do this without VBA by using a named range. EVALUATE is an old Excel v4 function that its use of will require saving as a macro-enabled workbook, but you won't need any VBA code.
Assuming your f(x) formula is entered in cell B5, and your x variables start in cell A8. Then highlight cell B8 and goto Formulas tab and click 'Define Name'.
Enter a name (e.g. 'f_x') and in the 'Refers to:' field enter this formula =EVALUATE(SUBSTITUTE($B$5, "x", ADDRESS(ROW($A8),COLUMN($A8))))
Then in cell A8, enter the formula =f_x and fill down.
You can fill down as far as you like and use some IF statements or something to hide anything beyond the end point.

Split list into two lists depending on adjacent cell value

I need a little help, I have an Excel book with a long list of customers and in the adjacent cell is ether a 1 or 0 depending if the customer has ordered in the past month.
How can I split this list into 2 lists on another page one been ordered in the past month and the other not ordered,
Im unable to use Macros due to security levels on the PC.
Thanks
Try,
'for ones
=INDEX(A:A, AGGREGATE(15, 7, ROW(B$2:INDEX(B:B, MATCH(1E+99, B:B)))/(B$2:INDEX(B:B, MATCH(1E+99, B:B))=1), ROW(1:1)))
'for zeroes
=INDEX(A:A, AGGREGATE(15, 7, ROW(B$2:INDEX(B:B, MATCH(1E+99, B:B)))/(B$2:INDEX(B:B, MATCH(1E+99, B:B))=0), ROW(1:1)))
Of course, you will have to modify to suit the different worksheet.
See the image below. Using array formulas (Ctrl+Shift+Enter) I entered this into D2:D8:
=IFERROR(INDEX(A2:A8,SMALL(IF(B2:B8,ROW(A2:A8)-ROW(A1)),ROW(A2:A8)-ROW(A1))),"")
and this into E2:E8:
=IFERROR(INDEX(A2:A8,SMALL(IF(1-B2:B8,ROW(A2:A8)-ROW(A1)),ROW(A2:A8)-ROW(A1))),"")
Explanation
This is how Excel will calculate the first formula:
=IFERROR(INDEX(A2:A8,SMALL(IF(B2:B8,ROW(A2:A8)-ROW(A1)),ROW(A2:A8)-ROW(A1))),"")
=IFERROR(INDEX(A2:A8,SMALL(IF({1;0;1;0;0;0;1},{2;3;4;5;6;7;8}-1),{2;3;4;5;6;7;8}-1)),"")
=IFERROR(INDEX(A2:A8,SMALL(IF({1;0;1;0;0;0;1},{1;2;3;4;5;6;7}),{1;2;3;4;5;6;7})),"")
=IFERROR(INDEX(A2:A8,SMALL({1;FALSE;3;FALSE;FALSE;FALSE;7},{1;2;3;4;5;6;7})),"")
Since the second argument of SMALL is an array, it will find the 1st, 2nd, 3rd, etc. value, ignoring FALSE (it will return #NUM! for the 4th through 7th value).
=IFERROR(INDEX(A2:A8,{1;3;7;#NUM!;#NUM!;#NUM!;#NUM!}),"")
=IFERROR({"A";"C";"G";#NUM!;#NUM!;#NUM!;#NUM!},"")
={"A";"C";"G";"";"";"";""}

Row value in index formula

I'm using following formula:
=TRIM(IFERROR(INDEX(Data!$E$2:$T$75000,SMALL(IF(Data!$E$2:$T$75000='Master Data Analysis'!K22,ROW(Data!$E$2:$T$75000)),ROW(1:1))-1,16),""))
is there any chance to make this part ROW(Data!1:1) being dependent on another cell.
So lets say if desired cell says 1, than Row(1:1), however if that cell says 3, it will say Row(3:3).
What I believe Phylogenesis was trying to say is not that you should change ROW with INDIRECT, but make a =ROW(INDIRECT("Data!"&A1&":"&A1)) reference there (if the cell, where the row number is, is A1 (your "desired cell"))

If a particular word exists within a field then assign corresponding value from a table"legend"

Reference Spreadsheet >> Spreadsheet
- I need a formula in column B that searches through column A for text values that exist in the legend (column E), then if text is found, assign corresponding value that exists in column F.
The alternative for this is to use a formula, but instead of this, I want to use a table that I can modify rather than modifying the formula each time I need to update values.
This is the formula I currently have
=IF(ISNUMBER(SEARCH("First",A3)),"One",(IF(ISNUMBER(SEARCH("Second",A3)),"Two",(IF(ISNUMBER(SEARCH("Third",A3)),"Three",(IF(ISNUMBER(SEARCH("Fourth",A3)),"Four",(IF(ISNUMBER(SEARCH("Fifth",A3)),"Five")))))))))
Confirmed with ctrl+shift+enter
=INDEX($F$2:$F$20,MATCH(MIN(IFERROR(SEARCH(OFFSET($E$2,,,COUNTA($E$2:$E$20)),A2),LEN(A2))),SEARCH(OFFSET($E$2,,,COUNTA($E$2:$E$20)),A2),0))
Alternate without CSE or the volatile OFFSET function.
In B3 as,
=IFERROR(INDEX(F:F, AGGREGATE(15, 6, ROW(E$3:INDEX(E:E, MATCH("zzz", E:E)))/ISNUMBER(SEARCH(E$3:INDEX(E:E, MATCH("zzz", E:E)), A3)), 1)), "")
Fill down as necessary.
For a case-sensitive lookup, change SEARCH to FIND.
Late answer...
=LOOKUP(2^15,SEARCH($E$3:$E$8,A3),$F$3:$F$8)

vlookup - only return cell with text

I need to return a cell that has text in it, but am running into difficulty.
Above is a sample table I'm working with. What I'd like to be able to do, is lookup id 1 and have it output Rich. When I do a vlookup, however, it gives no output. And while vlookup min/max will output integers, they don't work with text. Does anyone know how I can scan multiple ids, but only output the filled text cell?
There may be a shorter formula for this but I banged this off quickly and it does dynamically truncate the ranges in column B down to the minimum number of rows necessary.
=INDEX(B:B, AGGREGATE(15, 6, ROW(B2:INDEX(B:B, MATCH("zzz",B:B )))/(ISTEXT(B2:INDEX(B:B, MATCH("zzz",B:B )))*(A2:INDEX(A:A, MATCH("zzz",B:B )))=D3), 1))
To retrieve a second, third, etc. entry change the k parameter of AGGREGATE to a COUNTIF and fill down.
=INDEX(B:B, AGGREGATE(15, 6, ROW(B$2:INDEX(B:B, MATCH("zzz",B:B )))/(ISTEXT(B$2:INDEX(B:B, MATCH("zzz",B:B )))*(A$2:INDEX(A:A, MATCH("zzz",B:B )))=D3), COUNTIF(D$3:D3, D3)))

Resources