Find element in a matrix in excel [duplicate] - excel

I have the following Excel spreadsheet:
A B C D E F
1 MFC2 MFC1 QFC Search Criteria: CW14
2 CW11 Column Name: MFC1
3 CW13
4 CW14
5 CW17
6 CW18
7 CW19
8
9
In Cells A1:C8 I have different calender weeks. All of them are unique!
In Cell E2 I want that the column name is displayed based on the value that is put in Cell E1.
In this case the search criteria is CW14 so the result should be column name MFC1.
I tried to modify the formula from this question but could not make it work:
E1 = INDEX($A$1:$C$1,MATCH(E$1,$A$2:$C$30,0))
This formula gives me #NV as result.
What do I need to change to get the desried result?

Use AGGREGATE instead of MATCH:
=INDEX(1:1,AGGREGATE(15,7,COLUMN($A$2:$C$30)/($A$2:$C$30=$E$1),1))

=INDEX($A$1:$C$1,MAX(ISNUMBER(FIND(E1,$A$2:$C$7))*COLUMN($A$2:$C$7)))

Related

Ignore text values in subtotal function

Excel-Sheet:
A B C D E
1 1.200
2 Product A 500
3 Product B 400
4 Product C OK
5 Product D #NA
6 Product E 300
7
8
In the above table I have list of products in Column A and some data about the products in Column B.
In Cell B1 I want to calculated the subtotal of Column B using =SUBTOTAL(9,B2:B6).
However, now I have the issue that Column B not only consists of numbers.
It can also have the data type text (OK, NA). Therefore, the result in Cell B1 currently is #NA.
Is there any kind of formula that I could use so only the number data is considered and the result is 1.200 as in the table above?
Please note:
This function =AGGREGATE(9,6,B2:B6) won't help me because I want to filter the list later on so I need to go with the SUBTOTAL.
Use 7 as the second criterion in AGGREGATE instead of 6 as it will also exclude hidden rows:
=AGGREGATE(9,7,B2:B6)
You can solve this, combining the Excel worksheet functions =Value() and =IfERROR():
The function =Value() gives the value of a number, and in case of text it gives an error.
=IfError() can be used to give 0 in that case.
So, imagine you have following situation:
Column A Column B Column C
1 =Value(A1) =IfError(B1;0)
3.5 =Value(A2) =IfError(B2;0)
AB =Value(A3) =IfError(B3;0)
abc10 =Value(A4) =IfError(B4;0)
This gives following results:
Column A Column B Column C
1 1 1
3.5 3.5 3.5
AB #Value 0
abc10 #Value 0
You can simply take the sum of column C.
So this is based on the summary in B1.
=SUM(IF(ISERROR(B2:B6),"",B2:B6))
You need to push Ctrl+Shft+Enter for this to work.
Hope it helps.

Identify if list contains not unique values without countif in a helper column

A B C
1 Product A 1 Error
2 Product B 1
3 Product C 2
4 Product C 2
5 Product D 1
6 Product E 1
7
8
In the table above I want to identify if the values in Column A are unique.
If there is at least one value which is not unique Error should be displayed in Cell C1.
In order to achieve this I went with helper Column B and with the following formulas:
Column B `=COUNTIF($A$1:$A$6,A2)`
Cell C1 =`IF(COUNTA($A$1:$A$6)<SUM($B$1:$B$6),"Error","OK")`
All this works fine.
Now, I am wondering if there is also way to avoid the helper column.
Basically, a formula that goes through Column A and if it identfies at least one not-unique value it should display Error in Cell C1.
use:
=IF(MAX(COUNTIF($A$1:$A$6,$A$1:$A$6))>1,"Error","OK")
This is an array formula and depending on one's version will require the confirmation of Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one has the dynamic formula UNIQUE() then:
=IF(COUNTA(UNIQUE($A$1:$A$6))<>COUNTA($A$1:$A$6),"Error","OK")
As a normal formula.
Another formula, that will work in Conditional formatting:
=SUMPRODUCT(--(MATCH($A$1:$A$6,A:A,0)<>ROW($A$1:$A$6)))>0

Find column name based on search criteria

I have the following Excel spreadsheet:
A B C D E F
1 MFC2 MFC1 QFC Search Criteria: CW14
2 CW11 Column Name: MFC1
3 CW13
4 CW14
5 CW17
6 CW18
7 CW19
8
9
In Cells A1:C8 I have different calender weeks. All of them are unique!
In Cell E2 I want that the column name is displayed based on the value that is put in Cell E1.
In this case the search criteria is CW14 so the result should be column name MFC1.
I tried to modify the formula from this question but could not make it work:
E1 = INDEX($A$1:$C$1,MATCH(E$1,$A$2:$C$30,0))
This formula gives me #NV as result.
What do I need to change to get the desried result?
Use AGGREGATE instead of MATCH:
=INDEX(1:1,AGGREGATE(15,7,COLUMN($A$2:$C$30)/($A$2:$C$30=$E$1),1))
=INDEX($A$1:$C$1,MAX(ISNUMBER(FIND(E1,$A$2:$C$7))*COLUMN($A$2:$C$7)))

Get the column number of a search criteria in a defined range

I have the following Excel spreadsheet:
A B C D E F G H
1 Search Criteria: Prod.D
2 Column: 4
3 Prod.A Prod.B Prod.C Prod.D Prod.E
4
5
In Range D3:H4 I have Product A to Product E listed.
Now, I want to achieve that when I put a product name into Cell C1 I will get back the Column Number of the product in the range.
In the example above I want to search for Prod.D within the Range D3:H4 and therefore the result in Cell C2 should be 4 since the search criteria appears in the fourth column within the defined range.
What formula do I need to achieve this?
Try this formula in cell C2:
=MATCH(C1,D3:H3,0)

VLOOKUP if only a part of the search criteria matches with the values in the table

I have the following Excel spreadsheet:
A B C
1 List Search Criteria Result
2 2019-01 9 2019-09
3 2019-02
4 2019-03
5 2019-04
6 2019-05
7 2019-06
8 2019-07
9 2019-08
10 2019-09
11 2019-12
12
In Column A I have a list of all months in 2019. In Cell B2 I want to search for a month by just enterring in the number of the month. The result should appear in Cell C2. Therefore, I tried to go with the following formula in Cell C2:
C2 =VLOOKUP(B2,$A$2:$A$13,1,FALSE)
The issue is now that basically my search criteria is not 2019-09. It is just 9 and therefore the VLOOKUP is not able to find it within Column A.
So far I came up with the following solutions to solve this issue:
a) Change the search criteria to ="2019-"&B2.
b) Add a helper column next to Column A in which I only dsiplay the number of the months
However, I am wondering if there is smarter solution which does the job within the VLOOKUP function directly (maybe a combination with the MID function)?
Based on the comments below the question there are two solutions to solve the problem:
Option A)
If the year in the list does not change and will be the same you can go with this formula:
=VLOOKUP(TEXT(B2,"\*00"),$A$2:$A$13,1,FALSE)
Option B)
If the year in the list changes you can go with this formula and edit the first parameter accordingly:
=VLOOKUP("2019-"&TEXT(B2,"00"),$A$2:$A$13,1,FALSE)

Resources