Conditional formatting based on largest value in range of cells - excel

I have an Excel sheet with a count of user logons at 3 different sites. I want to conditionally format a column (E) to output the location, based on the largest value in cell range columns B to D, example:
A | B | C | D | E
Name | Site1Logins | Site2Logins | Site3Logins | MainSite?
User1 | 200 | 0 | 50 | Site1
User2 | 0 | 20 | 120 | Site3
User3 | 10 | 80 | 40 | Site2
So, E should automatically populate the site based on the largest value of columns B, C & D. Is this possible?
Thank you.

What you are after isn't conditional formatting - that would be changing the Format of a cell rather than it's value.
A formula that would work for this task is:
="Site"&MATCH(MAX(B2:D2),B2:D2,0)
Though there are many ways in which you could achieve this

Related

Spreadsheet Formula to Sum Values Over A if B is not in a List of Values

I have a table that looks the following:
| A | B | C |
| 40 | 1 | 1 |
| 180 | 2 | 2 |
| 34 | 1 |
| 2345 | 3 |
| 23 | 1 |
| 1 | 2 |
| 4354 | 3 |
| 2 | 2 |
| 343 | 4 |
| 2 | 2 |
| 45 | 1 |
| 23 | 1 |
| 4556 | 3 |
I want to get the sum of all fields in A where B is neither 1 nor 2 or any other value from colum C. This column contains the values of B where values from A should not be considered for the sum.
I do not know which values B might contain, those values are random and could grow larger, I just wanted to make the example small. My current solution is
{=SUMIF(B1:B13,C1:C2,A1:A13)}
so i can set the lines that should be excluded from the sum in column C. Unfortunately, the current solution does not solve my problem but something different -- it sums up the corresponding entries by value in C. My preferred solution would look something like
=SUMIF(B1:B13,"<>{1, 2}",A1:A13)
=SUMIF(B1:B13,"<>"&C1:C2,A1:A13)
if that were possible (it isn't). I would like to have:
a field (with a list, for example) or column where i can put in the values of B that I do not want to be part of the sum over A.
a method that works with Open Office as well as Excel. I prefer an OO solution.
You could use an array formula so that you can multiply each value in A with a condition. That condition can be any valid Excel formula, so, for instance, you could use MATCH to test if the B value occurs in C:
=SUM((A1:A13)*ISNA(MATCH(B1:B13,$C:$C,0)))
The ISNA function returns TRUE when the match fails, which in a multiplication is used as a numerical value 1. FALSE will make the product 0.
Make sure to enter this as an array formula with Ctrl+Shift+Enter

Excel compare corresponding values of the same index within two different columns

I have a sheet containing four columns in total A, B, C, and D. Column A has the corresponding value in B and Column C has the corresponding value in D. I want to use a formula that basically compares each corresponding value of Col A with the corresponding value of Col C.
| A | B | C | D |
| 1 | 100 | 2 | 2000 |
| 2 | 200 | 3 | 3000 |
| 3 | 300 | 1 | 1000 |
The above shows that 100 is the corresponding value of index 1 and 1000 is the corresponding value of the same index but in another column. How can i list them next to each other depending on index like below please.
| 1 | 100 | 1 | 1000 |
| 2 | 200 | 2 | 2000 |
This whole concept is then to match both corresponding values and see if they match or not. Thanks a lot.
if you are working on a very long list with the index in column A & C are not completely identical, then you can use vlookup() or index()+match() to create your table. Otherwise, just sort column C & D as Trauger suggested.

Return array of all matches between two ranges

Ok so I am trying to take a common tutorial array formula a step further but cannot figure out how.
Essentially I have a set of sheets with values like below:
| Sheet 1 || Sheet 2 |
| Products(1) | Product Group || Products(2) | Data |
| | || | |
| 100 | 1 || 100 | abc |
| 200 | 2 || 200 | def |
| 300 | 3 || 200 | ghi |
| 400 | 3 || 500 | jkl |
| 500 | 2 || 400 | mno |
Sheet 1 lists all parameters that classify each product and uses those to assign each product to a group. Essentially Products is a unique index key.
Sheet 2 is a tracking list of every time that a product is run, how it did. Therefore product numbers may show up multiple times or not at all.
I have a third sheet in which a product number is entered, from that its group number is calculated, and sheet 1 is searched for all products with that group number and the list is returned using an array formula (using this tutorial http://thinketg.com/how-to-return-multiple-match-values-in-excel-using-index-match-or-vlookup/ which shows up all over on line by different people). We will call this "Column K" on Sheet 3.
What I want to do now is take it a step further and return "Data" from Sheet 2 for all matches between "Sheet 2"!"Products(2)" and "Sheet 3"!"Column K". If "Column K" was fixed I could use the same formula again and put an OR statement into the IF expression, but because K is dynamically populated I am not sure how to find them all.
For clarification, The end result that I would ideally show is like this:
| Sheet 3 |
| Product Num | Column K | Column L | Column M |
| (user enters) | (automatic) | (automatic) | (automatic) |
| 500 | 200 | 200 | def |
| | 500 | 200 | ghi |
| Product Group | | 500 | jkl |
| (automatic) | | | |
| 2 | | | |
If you compare a column vector with an row vector in an array formula then it will compare each value from the column with each value in the row. So the following will work because we transpose the values in Sheet3!K1:K[n] into a row vector before comparing with Sheet2!$A$1:$A$10000.
Sheet1:
Sheet2:
Sheet3:
Formulas in Sheet3:
In A5:
=VLOOKUP($A$2,Sheet1!$A:$B,2,FALSE)
In K2 downwards:
{=IFERROR(INDEX(Sheet1!$A$1:$A$10000,SMALL(IF(Sheet1!$B$1:$B$10000=$A$5,ROW(Sheet1!$B$1:$B$10000)),ROW(1:1))),"")}
In L2 downwards:
{=INDEX(Sheet2!$A$1:$A$10000,SMALL(IF(Sheet2!$A$1:$A$10000=TRANSPOSE($K$1:INDEX($K:$K,MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000))))),ROW(Sheet2!$A$1:$A$10000)),ROW(1:1)))}
In M2 downwards:
{=INDEX(Sheet2!$B$1:$B$10000,SMALL(IF(Sheet2!$A$1:$A$10000=TRANSPOSE($K$1:INDEX($K:$K,MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000))))),ROW(Sheet2!$A$1:$A$10000)),ROW(1:1)))}
Formulas in K2,L2,M2 are array formulas. Input them without the curly brackets and then press [Ctrl]+[Shift]+[Enter].
The reference to K[n] in Sheet3!K1:K[n] is computed with
INDEX($K:$K,MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000))))
therein the
MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000)))
gets the largest row number in column K where the content not equals "".
If the product numbers are ever numeric, then it is easier and it will be possible to have the results sorted also.
Sheet1 and sheet2 see above.
Sheet3:
Formulas in Sheet3:
In A5: see above
In K2 downwards:
{=IFERROR(SMALL(IF(Sheet1!$B$2:$B$10000=$A$5,Sheet1!$A$2:$A$10000),ROW(1:1)),"")}
In L2 downwards:
{=SMALL(IF(Sheet2!$A$2:$A$10000=TRANSPOSE($K$2:INDEX($K:$K,MATCH(MAX($K:$K),$K:$K))),Sheet2!$A$2:$A$10000),ROW(1:1))}
In M2 downwards:
{=INDEX(Sheet2!$B$1:$B$10000,SMALL(IF(Sheet2!$A$1:$A$10000=$L2,ROW(Sheet2!$A$1:$A$10000)),COUNTIF($L$2:$L2,L2)))}

Check if cells match in two columns and, if they do, copy a related value

Given a column A of 100 names and another B of numbers, where column C contains a subset of those numbers how might I populate column D with the matching name? A match is where the names in A and D are next to the same number. For example, A, B and C are inputs and D the desired output:
____A______B_______C_______D____
1 |Larry | 11111 | 22222 | Bob |
2 |Bob | 22222 | 44444 | Steve |
3 |Mike | 33333 | 55555 | Jim |
4 |Steve | 44444 | | |
5 |Jim | 55555 | | |
Please try in D1 and copied down to suit:
=INDEX(A:A,MATCH(C1,B:B,0))
Not quite sure if this is what you are looking for, but a Vlookup function should help you greatly. I used a helper column to link C1 = A1, C2=A2 and so on. You can hide this column if you need to. You can then use the formula shown below in cell E1 and drag it down. As you put numbers in column D, the name will automatically fill in column E with the matching code.

Using a number in a cell to generate a cell reference

What I want to do might be better achieved with a database, however I have very limited experience with them, and only have to change the information infrequently.
What I have is a sheet where each row has 8 cells of relevant data.
What I want to do in another sheet is to enter a number into 1 cell, and have a group of cells below use that number to reference data in the other sheet.
For example, in Sheet1 I could have the following (fig 1):
| A | B | C | D | E | F | G | H
-----+-----+-----+-----+-----+-----+-----+-----+-----
101 | Dep | 700 | Sta | 100 | Sta | 300 | Dep | 900
What I want to achieve in sheet 2, by typing the row number into 1 cell, is to have the data in those 8 cells copied below, for example (fig 2):
| A | B | C | D |
-----+-----+-----+-----+-----+
1 | "Row Number" |
-----+-----+-----+-----+-----+
2 | =A# | =B# | =D# | =C# |
-----+-----+-----+-----+-----+
3 | =E# | =F# | =H# | =G# |
-----+-----+-----+-----+-----+
And yes, I am aware those formulae above do not reference the other sheet - this was to save space.
Which, if using the example row above, should look like this (fig 3):
| A | B | C | D |
-----+-----+-----+-----+-----+
1 | 101 |
-----+-----+-----+-----+-----+
2 | Dep | 700 | 100 | Sta |
-----+-----+-----+-----+-----+
3 | Sta | 300 | 900 | Dep |
-----+-----+-----+-----+-----+
So, in that example above (fig 3), what do I need to put in as a formula in cells A2-D2 & A3-D3 to automatically use the number in A1 as part of the cell reference to print the data from the other sheet.
Does that make sense? I hope so because I have over 300 lines to enter into my 1st sheet and another 70 lines x 7 blocks of columns on the second sheet.
Lastly I just want to say I want to avoid programming languages, like VBA, wherever possible.
Check out the INDIRECT() function.
For cell A2 in your example on the second sheet, enter:
=INDIRECT("Sheet1!"&"A"&$A$1)
Expand this formula to the apply to other target cells by changing the "&"A" portion to reference columns B, C, D, etc. from Sheet1 as needed in your grid per the following example:
=INDIRECT("Sheet1!"&"B"&$A$1)
=INDIRECT("Sheet1!"&"C"&$A$1)
=INDIRECT("Sheet1!"&"D"&$A$1)
These formulas will reference your selected "Row Number" in cell A1 and pull the related data from Sheet1 into Sheet2.
You can do this using the INDIRECT function
Returns the reference specified by a text string.
References are immediately evaluated to display their contents.
Use INDIRECT when you want to change the reference to a cell within a
formula without changing the formula itself.
http://office.microsoft.com/en-gb/excel-help/indirect-HP005209139.aspx

Resources