I have data in column A and B have lookup data.
For A2 (FY|F|V|D|Safety|3M). take the B column first value and search whether there is any match if not take second value in B column and repeat the process for all the B column values and if there is match print the B column value in Result. Does that make sense?
I tried with VLOOKUP but no luck. Please help me.
Columns:
A B(Lookup) C(Result)
FY|F|V|D|Safety|3M Toro 3M
FY|F|V|D|POP|ToroDays 3M Toro
FY|F|V|D|Lumber|GroundContact honeywell NA(Not available)
FY|F|V|D|airfilters|honeywell samsung honeywell
Enter the following formula in Cell C2
=IFERROR(INDEX($B$2:$B$5,MATCH(TRUE,IF(FIND($B$2:$B$5,A2)>0,TRUE),0)),"NA")
This is an array formula so commit it by pressing Ctrl+Shift+Enter. Drag/Copy down as required. Change range as needed.
See image for reference.
NOTE : Above formula is case-sensitive. If you want non-case-sensitive result you can use following formula.
=IFERROR(INDEX($B$2:$B$5,MATCH(TRUE,IF(FIND(UPPER($B$2:$B$5),UPPER(A2))>0,TRUE),0)),"NA")
In C2, put this and drag down:
=IF(ISERR(SEARCH($B2,$A2)),"N/A",$B2)
Here you go. A Google docs spreadsheet you can see.. The screenshots are from it.
Formulas
Results
You could have string with Toro3M in it, or all 4 for that matter.
The solution I have solves that. But you'd need to tweak to add commas or some such seperator.. And conditionally do it if cell in column F-I are zero length.
Related
E.g. I want to check if array (B1:B10) concatenated with (C1:C10) contains the text in cell A1, and if it does, return "Detected".
Some background info:
1) When those 2 arrays are concatenated together, they should have same length as A1.
2) Arrays concatenated with equivalent range value e.g. B1 with C1, B2 with C2.
EDIT
Using BigBen's template below, I tried =IF((MATCH(LEFT(A1,3),B1:B10,0)=MATCH(RIGHT(A1,3),C1:C10,0)),"detected","")
and managed to get the desired result; however, it does not account for duplicates 'bar' within column C.
enter image description here
enter image description here
IIUC, you can use MATCH for this:
=IF(ISNUMBER(MATCH(A1,B1:B10&C1:C10,0)),"Detected","")
IMPORTANT: Note that depending on your version of Excel, you may need to enter the formula with Ctrl+Shift+Enter.
This is probably very brittle, but given the data outline in BigBen's answer, this array formula (needs to be confirmed with Ctrl+Shift+Enter) returns the expected result:
=IF(ISNUMBER(SEARCH(A1,TEXTJOIN("|",FALSE,B1:B10&C1:C10),1)),"Detected","")
It basically joins each value in column B with the corresponding value in column C, then checks to see if the key word is detected in the resulting string. It is also dependant on you having a version of Excel that has the TEXTJOIN function.
Here is a view of the formula evaluation:
*note, I trimmed the data down to only 5 records, but you get it...
How do I find either the cell address or preferably the row and column of the value 119, or any other number in the table below?
The table does not contain row or column titles, only the numbers as shown.
I am looking for a worksheet solution (formula) and not a VBA solution.
An Array Formula
This is an array formula and it has to be entered with control shift enter i.e. hold control shift and then press enter.
=MAX(IF(A1:J34=119,ROW(A1:J34)-ROW(A1)+1))
Remarks:
The value is searched by column i.e. A1, A2, ... B1, B2 ... i.e. if you had another 119 in cell D1 the result would still be 2, and if you had a 119 in cell c1 then the result would be
1.
For a column version just replace ROW with COLUMN:
=MAX(IF(A1:J34=119,COLUMN(A1:J34)-COLUMN(A1)+1))
Well, clunky and you can expand it, but it does work:
Row is separate to column but you could put them together in one cell, does depend on how you want to use the results, but you did not specify that so I have done this...
You could use a choose() function or a lookup table with vlookup() to change the column result to a letter...
Please try:
=MOD((K1-50),34)+1&" | "&1+(INT((K1-50)/34))
where K1 is your selected value.
Returns R | C. (Data in A1:J34 is not required.)
Below is a general purpose answer based on VBasic2008's answer.
I modified the formulas to utilize defined names so that the cell references do not have to be hard coded in the formulas. This way both the data table and row / column formulas can be relocated to anywhere on the spreadsheet. It works for both numerical AND text based data.
I also included the =ADDRESS() function to return the absolute reference of the look up value.
For illustration purposes, a step by step example for Data Set 1 is shown replacing the hard coded cell references with defined names.
The Data Set 2 section is the simplified version just using one defined for each the row and column look up value.
You can download an example spreadsheet here: Look_Up_a_Value_in_a_Table.xls
Thanks to all of you: Solar Mike, VBasic2008, and pnuts
Click on the image to enlarge.
This gets a bit too expert for me, hopefully one of you can help me!
See the image for what I am trying to achieve. The red text shows what I want. List3 contains all the possible values for List1. List2 displays the currently active values for List1, and I want to return the missing values based on List3.
I'm guessing I'm looking at a MATCH/INDEX/IF function but I cannot figure this one out. Anyone out there willing to give me a hand? <3 Thanks a bunch!
Put this formula in F4 and fill down.
=INDEX(C:C, AGGREGATE(15, 7, ROW(C$2:C$11)/NOT(COUNTIFS(B:B, C$2:C$11, A:A, E4)), COUNTIF(E$4:E4, E4)))
Of course, this formula is dependent on the list of 'numbers' in E4:E7 being accurate and sufficiently populated to catch all missing entries.
Reference the image below. Use this formula to get the number missing:
=SUMPRODUCT(--(A2:A40<>A1:A39))*ROWS(C2:C12)-ROWS(A2:A40)
Change A40 to the last cell of your data in column A and A39 to the second to last cell.
Then enter this helper column as an array formula (Ctrl+Shift+Enter) into a 1-column range with the same number of rows that the formula above returns (it encodes the missing pairs into a single number). I entered it into D4:D8:
=SMALL(IFERROR(0>MATCH(INDEX(A2:A40,INDEX(SMALL(IF(A2:A40<>A1:A39,ROW(A2:A40)-ROW(A1)),ROW(INDIRECT("1:"&SUM(--(A2:A40<>A1:A39))))),INT((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1)/ROWS(C2:C12))+1))&INDEX(C2:C12,MOD((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1),ROWS(C2:C12))+1),A2:A40&B2:B40,0),INDEX(SMALL(IF(A2:A40<>A1:A39,ROW(A2:A40)-ROW(A1)),ROW(INDIRECT("1:"&SUM(--(A2:A40<>A1:A39))))),INT((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1)/ROWS(C2:C12))+1)*ROWS(C2:C12)+MOD((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1),ROWS(C2:C12))+1),ROW(INDIRECT("1:"&SUM(--(A2:A40<>A1:A39))*ROWS(C2:C12)-ROWS(A2:A40))))
Again, change A40 to the last cell of your data in column A and A39 to the second to last cell.
Next, enter this formula into E4 and fill down:
=INDEX($A$2:$A$40,INT(D4/ROWS($C$2:$C$12)))
Finally, enter this formula into F4 and fill down:
=INDEX($C$2:$C$12,MOD(D4,ROWS($C$2:$C$12)))
I have a row that will have weekly values entered. Column B has the initial value, and E has the calculation; as I add values to C, D and so on, I want the calculation to skip the previous columns value when the next column gets a value.
B1-C1=E1 BUT when a value is added to D1, E1 would update to B1-D1=E1
Sorry for the horrible description. This is probably answered somewhere on this site but I am not sure what terms to search.
Many thanks!
you can use an if statement. I am not 100% sure of your problem but something like this might be helpful.
if(A1, A1, 0)
So for your example provided.
=B1-if(D1, D1, C1)
This says if there is a value in D1 use D1 else use C1. This works in this example, because if
D1 is empty or 0 you will use the other cell. This may change for any given problem.
Use this if function in E1:
=IF(D1>0,B1-D1,IF(C1>0,B1-C1,B1))
Then enter a value in B1, then C1 then D1 to see the results.
According to your question, you only have room for two entries after the default B1 value. This statement will handle that.
If you need more fields, nest more if functions. But if's can only be nested 7 deep, so you can only have an initial value in B1 and 7 more cells, C1 to I1 with your formula in J1
If you actual data is as simple as your sample data you could just use:
=IF(LEN(D2)>0, B2-D2,B2-C2)
You could also use:
=IF(ISBLANK(D2), B2-C2, B2-D2)
if you prefer but Len is a little shorter and I believe the ISBLANK() function has flaws, If you have a formula in D2 that has a calculation and you set the result to "" then it will pick up as false. It depends on your needs.
I would do the following.
In E1 paste the following:
=A1-INDEX(B1:D1,1,COUNT(B1:D1))
The count formula will tell how many values are present in the range of B:D column. This will be used to catch the last column with an index formula which will be deducted form A1.
One thing is very important! The values from A to D has to be written in sequence, if one column is missing than the calculation will be false.
Hope I could help!
I have an excel workbook that I need some help with INDEX and MATCH or any other Formula that can get me my end result.
Here is sheet1:
SIT_ID METER SUSE_CD
10834282 DT0061 B
10834282 AW7931 P
21676286 CQ9635 P
21676286 DP4838 B
21726281 AW7880 P
21726281 DT0032 B
Here is Sheet2:
Site ID B P
10834282
21676286
21726281
Ultimately what I am trying to do is on Sheet2 is put the Meter that = B for the SITEID in the column and then Put the Meter that = P in the Same row.
I have never used Index or Match and I looked it up online but I am confused and hoping someone can help me with the correct formula or point me in the right direction.
Thanks so much!
INDEX first takes a range, then a row number, an optional column number (and an optional area number).
MATCH takes a value to lookup, an array and a mode.
In your problem you can use the following in Sheet2 cell B2:
=INDEX(Sheet1!$B$2:$B$7, MATCH($A2, IF(Sheet1!$C$2:$C$7=B$1,Sheet1!$A$2:$A$7), 0))
This formula is an array formula and will work with Ctrl+Shift+Enter and then you can fill it to the other cells.
I had to use an IF because there're two conditions to check.
EDIT: Use this one if your cell formats are different:
=INDEX(Sheet1!$B$2:$B$7,MATCH($A2*1,IF(Sheet1!$C$2:$C$7=B$1,Sheet1!$A$2:$A$7*1),0))
EDIT2: Adding trimming:
=INDEX(Sheet1!$B$2:$B$7,MATCH($A2*1,IF(TRIM(Sheet1!$C$2:$C$7)=TRIM(B$1),Sheet1!$A$2:$A$7*1),0))
EDIT3: If you're using it on your full data, change the range:
=INDEX(Sheet1!$B:$B,MATCH($A2*1,IF(TRIM(Sheet1!$C:$C)=TRIM(B$1),Sheet1!$A:$A*1),0))
Assuming your Sheet1 looks like this:
And your Sheet2 looks like this:
The formula in Sheet2 cell B2 and copied over and down to cell C4 is:
=INDEX(Sheet1!$B$2:$B$7,MATCH(1,INDEX((Sheet1!$A$2:$A$7=$A2)*(Sheet1!$C$2:$C$7=B$1),),0))
Note that this is a regular formula, so no need for Ctrl+Shift+Enter
A helper column D is added to initial columns.
D2: =$A2 & $C2
Now it's possible to make a simple search of the concatenated SITE_ID and SUSE_CD:
H2: =MATCH($G2&" B";$D$2:$D$8;0)
The result would be a row number (=1 in this case) for the needed string in array $D$2:$D$8.
INDEX shows the value of the cell, found by counting n-th row (defined by MATCH) and m-th column (=2) in array $A2:$A$8 from the upper left cell (A2).
Altogether: =INDEX($A$2:$B$8;MATCH($G2&" B";$D$2:$D$8;0);2)
The easiest way to get around with this is,
to use concatenation operator in the match function.
Don't forget to use Ctrl+Shift+Enter
Use below formula in column B of Sheet 2
{=INDEX(Sheet1!$B:$B,MATCH(Sheet2!$A2&Sheet2!$B$1,Sheet1!$A:$A&Sheet1!$C:$C,0))}
And the below formula in column C of Sheet 2
{=INDEX(Sheet1!$B:$B,MATCH(Sheet2!$A2&Sheet2!$C$1,Sheet1!$A:$A&Sheet1!$C:$C,0))}
And then flash fill the remaining rows.