Find all rows that contains 4 specific values? - excel

I am using excel and I have a table of numbers with 6 columns from A to F and more than 1000 rows. For example, from my table,
4 17 37 38 47 53
8 43 54 55 56 60
4 18 21 25 38 57
15 25 37 38 58 59
4 16 19 20 27 43
18 32 47 50 54 56
i want to find if there is at least a row (it must be a row!) that contains the numbers 16 19 20 27. From this example, there is a match, but i don't know how to make a search or formula using four diferent numbers.
I feel like I need to use the match function but can't quite figure it out and I'm not sure about it. Does anyone know how to do this?
Thanks!

This should work:
=IF(AND(OR(A1=16,B1=16,C1=16,D1=16,E1=16,F1=16),OR(A1=19,B1=19,C1=19,D1=19,E1=19,F1=19),OR(A1=20,B1=20,C1=20,D1=20,E1=20,F1=20),OR(A1=27,B1=27,C1=27,D1=27,E1=27,F1=27)),"Yes","No")
Put it in a new column in the table. It will return a Yes if the row contains all 4 values, and a No otherwise. You can then filter the new column of Yes/No to search for a row with Yes

I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F#. Then in column G create a helper column that concatenates A:F into a delimited string. The formula in G1 is:
=":"&A1&":"&B1&":"&C1&":"&D1&":"&E1&":"&F1&":"
where I've used ":" for the delimiter (you can use any char that's not in your data).
The result in G1 is:
:4:17:37:38:47:53:
Now in H1 use this formula to search:
=NOT(ISERR(FIND(":"&$I$1&":",G1)*FIND(":"&$J$1&":",G1)*FIND(":"&$K$1&":",G1)*FIND(":"&$L$1&":",G1)))
Each FIND will return an INT if the value (with leading and trailing delimiters) is found and #VALUE! otherwise. So the product will be an INT if all values are found and #VALUE! otherwise. Wrapping the FINDs inside an ISERR makes the result prettier (TRUE/FALSE instead of #VALUE!), and inverting with NOT returns TRUE when all 4 values are found and FALSE otherwise.
Hope that helps.

Here's another way --- more elegant (no helper column). As before, I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F#. Then in column G use this ARRAY formula (CTRL-SHIFT-ENTER):
=NOT(OR(PRODUCT(A1:F1-$I$1)<>0,PRODUCT(A1:F1-$J$1)<>0,PRODUCT(A1:F1-$K$1)<>0,PRODUCT(A1:F1-$L$1)<>0))
Each PRODUCT term checks for the existence of one value and returns 0 when the value is found and a non-zero value otherwise. The results of each of the four PRODUCT terms is tested with <>0 which will return TRUE if a value is not found. Then OR with return TRUE if one or more values are not found and FALSE if all are found. That result is wrapped in a NOT so that the function result is TRUE when all four values are found.

Related

Sorting numbers and strings together, where strings are numbers that can be followed by letters

I need to sort an Excel sheet which has a mixture of actual numbers and text containing numbers possibly followed by text.
For example if the following list was randomised, the end result should be:
54 <-- Actual number
55
56
57
57B <-- Number followed by a letter
57M <-- Yet another letter
58
58M
59
59M
60
60B
61
61M
62
62B
63
64
65
66
90
99
99A
100
100B
100B2
120
120B
I tried a million different ways. However, I can't work out a way to sort the sheet like this.
Is there a way to do this? Some sort of "humanised" sorting?
Add a helper column with the following formula:
=TEXT(IFERROR(LEFT(A1,MIN(IF(ISERROR(--MID(A1,SEQUENCE(LEN(A1)),1)),SEQUENCE(LEN(A1))))-1),A1),"000")&IFERROR(MID(A1,MIN(IF(ISERROR(--MID(A1,SEQUENCE(LEN(A1)),1)),SEQUENCE(LEN(A1)))),LEN(A1)),"")
Then sort on that.
Note: Change the "000" to the same number of digits as the largest number in the list.
Also if one does not have SEQUENCE substitute that part with ROW($ZZ$1:INDEX($ZZ:$ZZ,LEN(A1))) The formula would then also need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
Sorted on Column A:
Sorted on Column B:

excel incrementation by consecutive numbers

I have a form, thanks to user JamTay317, That lists data depending on folder number (bold number in form). I need to copy it for all 1500 folders (about 400 pages)
Form is divided on 4 labels on a page for easier printing
form overview
Form get it's folder number (nr teczki) from list with all folders from another sheet called "lista teczek":
list of folders
For first 4 folder numbers I use formula:
A2='lista teczek'!A1
J2='lista teczek'!A2
A21='lista teczek'!A3
J21='lista teczek'!A4
When I copy whole page underneath it increments by 36 (number of rows between)
A38='lista teczek'!A37
J38='lista teczek'!A38
A57='lista teczek'!A39
J38='lista teczek'!A40
Instead of A5, A6, etc.
Is there any way to override excel's incrementation to force it to use consecutive numbers? Or at least formula which will make it easier to follow folders list?
So I would use offset() to get the correct position
=A2=OFFSET('lista teczek'!$A$1;ROW(A1)-INT(ROW(A1)/36)*36+4*INT(ROW(A1)/36)-1;0)
So this will offset from A1 in the list sheet.
Below are row numbers a resultant lookup row numbers
Note the formula I used in the offset has an extra "-1" as this is an OFFSET so to get 1 from 1 we need to offset by 0
1 1
2 2
3 3
4 4
37 5
38 6
39 7
40 8
73 9
74 10
75 11
76 12
109 13
110 14
111 15
112 16
145 17
146 18
147 19
----LOGIC--- (edit)
So the idea is that you work out the occurrence you are on. Int(row()/36) gives us this. For example
int(1/36)=0
Int(363/36)=10
First part gives us the offset from the start of the occurrence
3-int(3/36)*36=3
378-Int(363/36)*36=3
Second part give the total of the previous occurrence
4*int(3/36)=0
4*Int(363/36)*36=40
So you need to change the 36 to the gap between the occurrences and the 4 to the length of occurrences Not sure if that helps to explain

Countif after filterlist Excel

I would like to see a working example of how to get this formula properly working
=SUMPRODUCT(SUBTOTAL(3,OFFSET($P$7,ROW($P$8:$P$5500)-ROW($P$7),,1)),--($P$7:$P$5500="74"))
What im trying to achieve is count all the cells within a range that value is greater than
zero, but i need to get that working after i apply a filter. I have seen several examples and havent get it working, with the subtotal fx.
Thanks in advance, for any help!
Working example:
O P
4
5 6
6
7 Filter Data
8 1 74
9 0 74
10 1 74
11 0 74
12 1 74
13 0 74
Formula in P5:
=SUMPRODUCT(SUBTOTAL(103,OFFSET($P$7,ROW($P$8:$P$20)-ROW($P$7),,1)),--($P$8:$P$20=74))
Now you can filter column O and P5 counts only the visible 74.
With function 103 in SUBTOTAL, I really count only the visible cells. This means, also the manually hidden cells are not counted. With function 3 only the out filtered cells are not counted. If cells are manually hidden, they are counted, even if they are not visible.
And I have used the value 74 instead of the text "74". So in my example the column P contains numbers, not text.
How it works:
The formulas within SUMPRODUCT are in array (matrix) context. This means they are handled as if they are used in array formulas.
In array context {ROW($P$8:$P$20)-ROW($P$7)} gets ROW($P$8)-ROW($P$7) = 1, ROW($P$9)-ROW($P$7) = 2, ROW($P$10)-ROW($P$7) = 3 and so on.
OFFSET($P$7,1,,1) will get $P$7+1Row = $P$8, OFFSET($P$7,2,,1) will get $P$7+2Row = $P$9 and so on.
So {OFFSET($P$7,ROW($P$8:$P$20)-ROW($P$7),,1)} gets {$P$8,$P$9,$P$10,...}
Within SUBTOTAL(103, {$P$8,$P$9,$P$10,...}) it counts 1 if {$P$8,$P$9,$P$10,...} is visible and 0 if not.
So the SUMPRODUCT results in
SUMPRODUCT({1,0,1,0,1,0,0,...}, --($P$8:$P$20=74))
The {($P$8:$P$20=74)} results in {TRUE,TRUE,TRUE,FALSE,TRUE,...} depend of if $P$8:$P$20=74. The -- (*-1*-1) gets this in numeric context, so that the TRUE = 1 and FALSE = 0.
So the SUMPRODUCT finally results in
SUMPRODUCT({1,0,1,0,1,0,0,...}, {1,1,1,1,1,1,0,...})
Greetings
Axel

Excel nesting error

I'm using Excel 2013 and I have had to create a If statement which basically chooses a student's grade depending on a certain mark number (obviously, nesting is needed) Here is the If statement I created:
=IF(E2<=20,"N",
IF(OR(E2>=21,E2<=25),4,
IF(OR(E2>=26,E2<=32),"5C",
IF(OR(E2>=33,E2<=38),"5B",
IF(OR(E2>=39, E2<=44), "5A",
IF(OR(E2>=45, E2<=53), "6C",
IF(OR(E2>=54, E2<=61), "6B",
IF(OR(E2>=62, E2<=71), "6A",
IF(OR(E2>=72, E2<=87), "7C",
IF(OR(E2>=88, E2<=103), "7B",
IF(OR(E2>=104, E2<=120), "7A")))))))))))
The error I receive is:
the specified formula cannot be entered because it uses more levels of nesting than allowed in the current file format
My question is, how do I shorten this statement to allow Excel to use it?
Place the logic in the spreadsheet cells. One column for the minimum score, and one column for the grade-:
A B
1 0 N
2 21 4
3 26 5C
4 33 5B
5 39 5A
6 45 6C
7 54 6B
8 72 7C
9 88 7B
10 104 7A
Then do a vlookup to get the grade from the actual score. vlookup will find the highest value in the A column that is less that the lookup value of 38.
In the example vlookup below 38 is the score, A1:B10 is the lookup table 2 is the 2nd column (in this case the B column) that contains the result (the grade).
=VLOOKUP(38, A1:B3, 2, TRUE)
You can also use the following formula.
=LOOKUP(E2;{0;21;26;33;39;45;54;62;72;88;104;121};{"N";4;"5C";"5B";"5A";"6C";"6B";"6A";"7C";"7B";"7C";"No match"})
There are a few different solutions. AND agreements using OR instead of the first that comes to mind.
=IF(E2<=20,"N",
IF(AND(E2>=21,E2<=25),4,
IF(AND(E2>=26,E2<=32),"5C", ...
The best way, in my opinion, is to write a UDF. Then you can use VBA and a CASE statement.
Experiment with this code in VBA to create a UDF named GRADE() - just type it into a MODULE in the VBE:
Function Grade(Marks)
Dim Score As Integer
Score = Marks * 1
Select Case Score
Case 1 To 20
Grade = "N"
Case 21 To 50
Grade = "C"
Case 51 To 90
Grade = "B"
Case 91 To 120
Grade = "A"
End Select
End Function
Then use the Function GRADE() as you would any other function but type the address of the argument - like this GRADE(B7) to use it
=+IF(O3="Negative","Negative",IF(P3="Negative","Negative",IF(Q3="Negative","Negative",IF(R3="Negative","Negative",IF(O3="Refer","Refer",IF(P3="Refer","Refer",IF(Q3="Refer","Refer",IF(R3="Refer","Refer","Positive"))))))))
I find the final status in 4 cells have positive,negative,refer,pending or blank

Find what range a number belongs to

Ive written a function to calculate what MARK a student gets, based on a scoring table.
Why does my function work only for A mark?
This what the excel sheet looks like
COLUMN: A B C
Student SCORE MARK
1 adsf 90 A
2 asgfd 89 FALSE
3 A 90 100
4 B 81 89
5 C 71 80
6 D 61 70
7 E 56 60
8 Fx 0 55
This is the function:
{=IF(B1>=$B$3:$B$8,IF(B1<=$C$3:$C$8,$A$3:$A$8))}
I'm using {} brackets for array functions. (CTRL SHIFT ENTER)
Thank you
You're on the right track but your formula is returning an array not a single value. Wrapping the result in LOOKUP should give the desired result:
=LOOKUP("Z",IF(B1>=$B$3:$B$8,IF(B1<=$C$3:$C$8,$A$3:$A$8))
This returns the last matching grade since "Z" is larger than any other text value in the range.
A simpler method is:
=LOOKUP(-B1,-C$3:C$8,A$3:A$8)
The negative signs are needed so that the lookup values are in ascending order.

Resources