Each row of 4 columns represents a set of data
A1 : D1 1,2,3,4
A2 : D2 4,2,1,5
A3 : D3 5,3,2,1
etc.
Now the column set will be compared to another column set
F1 : I1 4,6,3,1
F2 : I2 4,3,2,1
F3 : I3 2,3,5,1
The set that matches to the other column set will be marked red. So in the example F2:I2 and F3:I3 will be marked red. They just need to contain the same numbers. The order is not important but all numbers should match.
I thought of using conditional statements but can't seem to find a way to compare and match sets of range to other sets of range.
As an alternative, I thought of adding all the columns =A1&" "&A2&" "&A3&" " &A4 then sort it then match it from there but I tried sorting from left to right the sets and it doesn't seem to be sorting right if I do it all at once. The sheet will contain a large amount of rows so that will be a chore to do it 1 by 1.
So I'm out of ideas as I am not that good with excel. :(
Appreciate all the help I can get. :)
Also, I don't mind learning other languages if it makes things easier. (as long as I can import the data from an excel)
If you want to create a single column to match on then this should do it:
=CONCATENATE(LARGE(A1:D1,1),":",LARGE(A1:D1,2),":",LARGE(A1:D1,3),":",LARGE(A1:D1,4))
Then you can use the regular lookup functions such as MATCH()
Related
I have a worksheet that detects toxic combinations (two variables that are not supposed to exist together). In one sheet I want to cross all the variables there are and highlight the cell that crosses the two variables that are toxic.
for example cell E1 (variable 1) and A5 (variable 2) are toxic combinations, so i want to highlight cell E5 (this can be with a X or a formatting conditions, it doesn't matter).
On another sheet these toxic combinations are defined, simply by entering the two variables behind each other on the same row.
I'm having trouble understanding how to approach this. one thought is to enter a formula (if such exists) that goes something like the following:
=IF cell E1 and cell A5 are on the same row in worksheet ... then x else ""
So my question is: does anyone have experience with this situation, if so, how would/ did you tackle this. Or is there a formula that I can use demonstrated above? Or is it wise to use VBA?
Please let me know if anything is unclear.
Edit: screenshots
The worksheet where the toxic combinations are determined:
The worksheet where the toxic combinations are 'visible'
you can use vlookup for this.
Suppose in your SOD matrix, the element names are in column A and in row 1, and that in your SOD description the elements are in column C and E. And suppose that your SOD description is on a tab called "SODdesc"
the formula in cell C5 would be
=if(VLOOKUP($A5;SODdesc!C:E;3;0)=C$1;"TOXIC";"")
This only works if there are no duplicates in column C of the SOD description sheet.
Another possible solution that works also if there are duplicates, is to create an extra column (G) where for example G10 would be =C10&E10 and a column H, with H10 is =E10&C10
then the formula in C5 would become:
=if(not(isna(vlookup($A5&C$1;SODdesc!G:G;1;0)));if(not(isna(vlookup($A5&C$1;SODdesc!H:H;1;0)));"TOXIC";""))
I didn't create a whole file to test the formula's, but if you know a little bit how excel formulas work, you should get the idea.
I have a range of value (say H6:H20) containing values "g","y" or "r".
In order to count each status and use that as the source of a donut chart, I made a range of 3 cells calculating =COUNTIF($H$6:$H$20,"Green") etc...
Then I tried to be more elegant and create a single array formula returning the count for each letter, that I could eventually use as the source of my chart, without having intermediry calculation range. But I can't get this working.
Input:
g
r
y
g
g
r
g
g
y
Expected output (with a single array formula):
5
2
2
My try: =COUNTIF({"g","y","r"},$H$6:$H$20) -> error
Other try: =SUMPRODUCT(1*$H$6:$H$20={"g","y","r"}) -> error
(both entered in a 3 cells range with Ctrl+Shift+Enter, of course)
What is the right formula ?
You don't need an array formula, though you do need to store that formula as a Defined Name within Name Manager, e.g.:
Name: Series_Values
Refers to: =COUNTIF(Sheet1!$H$6:$H$20,{"g","y","r"})
Change the sheet name (Sheet1 here) as required.
You can then add a series to a chart with the following syntax for the Series values entry:
='Sheet1'!Series_Values
Again, amend the sheet name as required, though be sure to retain the exclamation mark and apostrophes (the latter are not strictly necessary if the worksheet name contains no spacing, though in any case it is good practice).
Excel will actually amend this to:
=Book1!Series_Values
(where Book1 is the assumed workbook name), though this is not important here.
Regards
That's what FREQUENCY function is for. Select 3 cells and CTRL+SHIFT+ENTER following formula:
=FREQUENCY(MATCH($H$6:$H$20,{"g","y","r"},0),MATCH($H$6:$H$20,{"g","y","r"},0))
Assuming this isn't dynamic, and you have a definite amount of rows, you can use the following. Let's say you're putting this formula in row 20:
=COUNTIF($A$1:$A$9,INDEX({"g","r","y"},ABS(20-(ROW()+1))))
and drag down.
Edit: If you want in the same cell, just combine COUNTIF()?
=COUNTIF($A$1:$A$9,"g")&","&COUNTIF($A$1:$A$9,"r")&","&COUNTIF($A$1:$A$9,"y")
=IF({"g","y","r"}="g",COUNTIF($H$6:$H$20,"g"),IF({"g","y","r"}="y",COUNTIF($H$6:$H$20,"y"),IF({"g","y","r"}="r",COUNTIF($H$6:$H$20,"r"))))
long solution as I don't have time to make a more elegant one. You can see the array object with F9 in the formula bar.
I'm entering datas in A column of a table. According to the datas, I making sums from the yellow cell (actually this yellow cell is the high value of the A column). So all 10 cells, there is a sum until the end of datas.
I'm looking for automatically report the seven first grey cells (the sums)to another table. The problem is, according to the datas, high value is not at the same place so the sums are not to the same place too.
How can I do ?
Thank you for your help
MY ERROR :
And the message when I press ctrl maj enter in same time :
You might use this array formula in your report.
=INDEX($F:$F,SMALL(ROW($F$4:$F$117)+(100*(F$4:$F$117="")), ROW(F1)))&""
Bear in mind that, as an array formula, it must be confirmed with Control+Shift+Enter. Enter the formula in the row where you have Somme = 1, then copy down to 6. Note that Row(F1) is a counter. You have a similar counter (1 to 6) in F124:F130. Therefore you can replace ROW(F1) with $F124 (if that is where the "1" is) to make it easier to understand, perhaps.
The formula retrieves the value of the 1st, 2nd, 3rd etc non-blank cell in the range F4:F117. If those cells contain a formula they will be considered "blank" if their result equals "".
BTW, if you don't always have 113 results to evaluate you might consider giving a name to the range E4:E117. For example, if you name that range as "Results" then =SUM(Results) would be the same as =SUM($E$4:$E$117), but as you insert or delete rows within the named range the formula doesn't need to be amended. Use of a named range would simplify understanding your existing formula. You could do the same with column F.
Finally I find a solution to report the values from F to another table. As values positions are dependant of the MAX raw in E (every 10 cells) I make this formula :
For the first : INDEX(E4:F117;EQUIV(GRANDE.VALEUR($E$4:$E$117;1);$E$4:$E$117;0)+10;2)
For the second :
INDEX(E4:F117;EQUIV(GRANDE.VALEUR($E$4:$E$117;1);$E$4:$E$117;0)+20;2)
Etc...
Hi all,
I have this excel where by I need to find the location of the item if they are found in column B.
So In my F column, I tried to write ifelse formula which didnt work.which is
=IF(D2="NULL","NONE",C((D2))).
My idea is if D2 is not null, use the value in D column to find the location in C column. In this example, fish no 4, so it is found, my F column should show the value "C" using the value shown in D column and use it as Row no in C column
I hope you guys get the idea and help me out a newbie in excel. Thanks in advance
=vlookup($D2,$A$2:$C$6,3,0)
you can use that in column F. Place that formula in F2 and copy down.
you could technically use it in column E as well, but you would need to change the 3 to a 2.
you did not say what you wanted to do if the D value was "Null" so I am going to take a stab at the dark and wrap you lookup formula in an if statement that will deal with "Null" or empty cells
=IF(OR($D2="NULL",$D2=""),"",VLOOKUP($D2,$A$2:$C$6,3,0))
That is the alternative formula to place in F2 and copy down.
Use the formula:
=IF(D2<>"NULL",VLOOKUP(D2,A2:C6,3,FALSE),"Value is NULL")
Here is the working example:
Put formula in cell F2 and drag it down.
[edit]to pull proper location column, not just the row #[/edit]
Seems like a job for MATCH+OFFSET
Try this formula in cell F2:
=OFFSET($C$1, MATCH(E2,B:B,0)-1, 0, 1, 1)
Match is used to locate the value in the first argument (ie E2) within the range specified in 2nd argument (ie B:B). I use B:B but you could also use range B2:B30 or whatever more specific range you want. (I prefer the more generic B:B, though :) )
Third paramter "0" just indicates "Exact match".
This function will retun "#N/A" if nothing found.
OFFSET takes the result from MATCH to pick out the Location you want. The first parameter in OFFSET is the rows below (or above if negative) from the base row (in this case $C$1). the next is the column: 0 since we're in the column we want to be in. The last two are the size of the range: 1,1 is a 1x1 cell, so just 1 cell. If we did ...,2,3), that would be 2 rows high and 3 columns wide - or a 6 cell range. We're just after 1 cell here.
I've always preferred MATCH + OFFSET to other options, I just found they held up more robustly to changes in a sheet (ie new rows/columns added). So it's mostly personaly preference over VLOOKUP and INDEX. I honestly have never compared their actual performance, however, I've never had any issues with MATCH+OFFSET running slowly :)
I am going crazy over this. It seems so simple yet I can't figure this out. I have two worksheets. First worksheet is my data. Second is like an answer key. Upon checking checking, A1:B1 in Sheet 1 is a match with the conditions in Row 52 in SHEET 2, therefore, the value in Column C is "MGC". What is the formula that will perform this function? It's really hard to explain without the data so I pasted a link of the sample spreadsheet. Thank you so much in advance.
sample spreadsheet here. https://docs.google.com/spreadsheets/d/1_AjuNfCdGfEM-XkqPa6W4hSIxQg4NM2Vg4c2C1pQ_vQ/edit?usp=sharing
screenshot here. (wont let me post i have no reputation)
In Sheet2, insert a column in front of Column A and put the formula in A2 =C2&D2.
Then in Sheet1, Cell C2 the formula =vlookup(A2&B2,Sheet2!A:B,2,0).
the first make a concatenated key to lookup, then the second looks up that key.
How about a index(match())? If I've understood correctly you need to match across both the A and B column in sheet one, checking for the relevant values in B and C on sheet 2 to retrun worksheet 2 column a to worksheet 1 column c.
third version try:
=INDEX(Sheet2!$C$1:$C$360,MATCH(Sheet1!A1&Sheet1!B1,Sheet2!$B$1:$B$360&Sheet2!$C$1:$C$360,0))
Basically what this does is use concatenation, the & operator, to specify you are looking for "Criteria A" & "Criteria B" in sheet 1, which makes the string "Criteria A Criteria B", which is supplied in the first part of the match function.
In the second it then says match this against all of my variables in sheet 2 in the same way with concantenation.
The final part of match function (0) specifies you want an 'exact' match
It then supplied this as a reference to the index function, which then finds the row intersecting with the value you want, and returns that.
As noted here https://support.microsoft.com/en-us/kb/59482 this is an array formula, so it behaves differently, and must be input differently. https://support.office.com/en-za/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7
There are (at least) 2 ways you could do this without VBA.
USING A SORTED LIST
The first relies on the assumption that your data can be re-sorted, so that everything "Unreported" is in the top, and everything "reported" is together below that (or vice versa). Assuming that this is the case (and it appears to already be sorted like this),we will use the function OFFSET to create a new range which shows only the values that align with either being "Unreported" or "Reported".
Offset takes a given reference to a point on a sheet, and then moves down/up & left/right to see what reference you want to return. Then, it returns a range of cells of a given height, and a given width. Here, we will want to start on Sheet2 at the top left, moving down until we find the term "Unreported" or "Reported". Once that term is found, we will want to move one column to the right (to pull column B from sheet 2), and then have a 'height' of as many rows as there are "unreported" or "reported" cells. This will look as follows in A1 on sheet 1, copied down:
=OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),1)
This says: First, start at cell A1 on sheet2. Then find the term in A1 (either "unreported" or "reported", on sheet2!A:A (we subtract 1 because OFFSET starts at A1 - so if your data starts at A1 we need to actually stay at "0". If you have headers on sheet2, you will not need this -1). Then, move 1 column to the right. Go down the rows for as many times as Sheet2 column A has the term found in Sheet1 A1. Stay 1 column wide. Together, this will leave you with a single range on sheet2, showing column B for the entire length that column A matches your term in sheet1 A1.
Now we need to take that OFFSET, and use it to find out when the term in Sheet1 B1 is matched in Sheet2 column B. This will work as follows:
=MATCH(B1,[FORMULA ABOVE],0)
This shows the number of rows down, starting at the special OFFSET array created above, that the term from B1 is matched in column B from sheet2. To use this information to pull the result from column C on sheet 2, we can use the INDEX function, like so:
=INDEX([FORMULA ABOVE],MATCH(B1,[FORMULA ABOVE],0))
Because this would be fairly convoluted to have in a single cell, we can simplify this by using VLOOKUP, which will only require the OFFSET function to be entered a single time. This will work as follows:
=VLOOKUP(B1,[FORMULA ABOVE],2,0)
This takes the OFFSET formula above, finds the matching term in B1, and moves to the 2nd column to get the value from column C in sheet2. Because we are going to use VLOOKUP, the offset formula above will need to be adjusted to provide 2 columns of data instead of 1. Together, this will look as follows:
FINAL FORMULA FOR SHEET1, C1 & COPIED DOWN
=VLOOKUP(B1,OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),2),2,0)
OPTION USING ARRAY FORMULAS
The above method will only work if your data is sorted so that the REPORTED and UNREPORTED rows are grouped together. If they cannot be sorted, you can use an ARRAY FORMULA, which essentially takes a formula which would normal apply to a single cell, and runs it over an entire range of cells. It returns an array of results, which must be reduced down to a single value. A basic array formula looks like this [assume for this example that A1 = 1, A2 = 2...A5 = 5]:
=IF(A1:A5>3,A1:A5,"")
Confirm this (and all array functions) by pressing CTRL + SHIFT + ENTER, instead of just ENTER. This looks at each cell from A1:A5, and if the value is bigger than 3, it gives the number from that cell - otherwise, it returns "". In this case, the result would be the array {"";"";"";4;5}. To get the single total of 9, wrap that in a SUM function:
=SUM(IF(A1:A5>3,A1:A5,""))
In your case, we will want to use an array formula to see what row in Sheet2 matches A1 from Sheet1, and B1 from Sheet1. This will look like this:
=IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW($B$1:$B$100),""),"")
This checks which rows in column A from sheet 2 match A1. For those that do, it then checks which rows in column B from sheet 2 match B1. For those, it pulls the row number from that match. Everything else returns "". Assuming no duplicates, there should only 1 row number which gets returned. To pull that number from the array of results, wrap the whole thing in a MATCH function. Now that you have the row number, you can use an INDEX function to pull the result in Column C with that row, like this:
FINAL ARRAY FORMULA METHOD
=INDEX($C$1:$C$100,MAX(IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW(Sheet2!$B$1:$B$100),""),"")))
Remember to confirm with CTRL + SHIFT + ENTER instead of just ENTER, when you type this formula. Note that I didn't refer to all of Sheet2!A:A, because array formulas run very slowly over large ranges.
The following formula should work without making any changes to the datasheets.
=INDEX(Sheet2!$A$1:$A$360,MATCH(Sheet1!A1,IF(Sheet2!$C$1:$C$360=Sheet1!B1,Sheet2!$B$1:$B$360),0))
Remember to save this formula as an array with CTRL+SHIFT+ENTER
Documentation on how to use INDEX and MATCH against multiple criteria can be found on Microsoft Support.
It's not clear what you want to do with the multiples that do not have corresponding matches. txed is listed as Unreported twice in Sheet1; kntyctap is listed as Unreported three times. There are only one corresponding match on Sheet2 for each of these.
Non-array Standard Formulas for multiple criteria matches
For Excel 2010 and above use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999,AGGREGATE(15,6,ROW(1:999)/((Sheet2!$B$1:$B$999=A2)*(Sheet2!$C$1:$C$999=B1)), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
For version of Excel prior to 2010 use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999, SMALL(INDEX(ROW($1:$999)+((Sheet2!$B$1:$B$999<>A1)+(Sheet2!$C$1:$C$999<>B1))*1E+99, , ), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
I've handled error with the IFERROR function in that latter formula. Excel 2003 and previous may have to use an IF(ISERROR(..., ...)) combination.