Excel Lookup between multiple columns - excel

I need your assistance with Excel. I have the following columns on my worksheet
EmployeeNumber, EmployeeName, SalesID,Email, EmployeeNumberID.
The EmployeeNumber and EmployeeNumberID columns are the key columns as these contain the employee number. The problem is that EmployeeNumber contains all employees from different departments and EmployeeNumberID contains employee from the Sales department.
Could you please assist with highlighting the EmployeeNumber that are not in the EmployeeNumberID column, if we could highlight the entire row that would be great.
Mnay Thanks

Assuming your data is layed out as per the image below, select the range from A2 to E9 and ensure that the upper left cell A2 is your active cell. Notice in the image the active cell has a light background compared to the grey background of the rest of the selected range.
Then go to your HOME ribbon and select conditional formatting.
From the drop down menu that appears select New Rule.
In the New Formatting Rule window that appears select "Use a formula to determine which cells to format" at the bottom of the list. Then click to format button and chose whatever formatting you want to have applied. I would recommend the Fill tab and then select a colour.
Enter the following logical check in the "Format values where this formula is true:" box:
=COUNTIF($E$2:$E$9,$A2)=0
It will count the number of times Employee number in column A occurs in Column E. It will then check to see if that count is zero meaning its not in column or not part of the sales team, and apply the formatting you selected early to all cells in the row from A to E. If you only want to colour cells in column A then select A2:A9 as your initial selection area for applying conditional formatting to. The equation should not need to change.
Proof of Concept

You just need some conditional formatting. Select the area you want to apply the highlighting to, lets say A:E, then use conditional formatting with the following formula:
=ISNA(MATCH($A1,$E:$E,0))
assuming EmployeeNumber is in column A and EmployeeNumberID is in column E.
What this does is tries to match the EmployeeNumber to a value in column E. If it fails, then it will return #N/A and ISNA will return TRUE and the row will be highlighted.
Note that $A1 should be the top left cell in the range you are formatting. If you start lower, adjust the cell accordingly.

Related

Conditionally Format Column if Cell in Column Contains Specific Text

I have a table that is updated monthly with formulas. Each month, a different column has the Total in it, I want to be able to automatically highlight the column that has the word "Total" in the first cell of the column. Any help is appreciated!
If you select the entire sheet (click the bit in the upper left hand corner of the page - above the 1 and left of the A) and make a conditional formatting rule like this it will highlight any column where the first cell in the column is the word Total

Conditional formatting for a column based on the value of header

I have several columns where the data from rows 7 onwards changes depending on the selection made from a dropdown menu in row 6. Most of these options will result in textual or number based values appearing, but two of them would need to be formatted as currency.
Essentially what I want is a conditional formatting formula that says; if row six in any column has a value of “Implied Unit Rate” or “Annual budget”, format rows 7 and onwards in that column as currency.
I can get this to work by creating two separate conditional formatting formulas and applying them both to the whole area, but it seems like there should be a way to do it in a single formula.
My current formulas, applied as two separate rules:
=INDIRECT(ADDRESS(6,COLUMN(),1))="Annual Budget"
=INDIRECT(ADDRESS(6,COLUMN(),1))="Implied Unit Rate"
How I think it should work when applied as one rule:
=OR(INDIRECT(ADDRESS(6,COLUMN(),1))="Annual Budget",
INDIRECT(ADDRESS(6,COLUMN(),1))="Implied Unit Rate")
When I enter the combined formula in a regular cell within the worksheet, it does return true as expected, but does nothing when I apply it as a conditional formatting rule. Any ideas? Thanks in advance!
Now I may be mis interpreting what Scott is saying, so I am going to say this in my own words.
Your condition check on the cell address in question is a little "verbose". In order to apply your conditional formatting, select the range you want to apply your condition formatting to first. Lets arbitrarily say select range A7 to D42. After selecting the appropriate range, ensure cell A7 is the active cell of the selected range. This usually means there is a border around A7 to D42 and all cells but A7 have been slightly greyed to indicate that they have been selected, and A7 will have a brighter background to indicate that it is the active cell. With all that still in effect, select your conditional formatting.
In conditional formatting choose formula as the option (last one at the bottom) to control how your formatting will be applied. In the region where you can enter your formula, enter the following:
=OR(A$6="Annual Budget", A$6="Implied Unit Rate")
The $ will keep the row and column reference from changing as it is applied to each cell in the range. It will always be checking row 6 of what ever column the cell is in. The column A reference is relative to the active cell.

Highlight cells based on 10-15 values and post alternatives

I have a 1600-2000 rows of data in a spreadsheet that changes daily. I would like to highlight any row that contains such as 000000000000053851 in the R column. I had tried conditional formatting using this formula:
=OR($R1="000000000000549543",$R1="000000000000267294,$R1="000000000000053851")
but it seems to highlight a few rows that are blank in column R also.
Using the same numbers highlighted in column R, I would like to have an alternate number and possibly other data pasted into the corresponding row in column S. Each number has a unique alternate number and data to go along with it. This is how I picture a line may look with the highlighting and alternate data next to it:
I intend to record a macro using a few of the different steps that are likely required to do this. Any way, whether conditional formatting or an array formula, would be great to help with this.
For the sample provided, a CF rule of:
=LEFT(R1,12)="000000000000"
applied to ColumnR will format the sample and if you wish the cell immediately to the right. It will not highlight blank cells.
HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true:, enter formula from above and Format... with Fill red, OK, OK.
If you want the cell to the right to be formatted also, select ColumnsR:S instead of just ColumnR and change R1 in the formula to $R1.
For the cell to the right you provide few details but VLOOKUP in conjunction with a two-column table should suit. Column on the left being the ColumnR value, with the right-hand column for the same row the ColumnS value required. This table could be placed almost anywhere.
This could all be done with Record Macro.

Set conditional formatting to compare content to cells in different sheet

Looking for a way to do conditional formatting on two Excel sheets. The spreadsheet is a log of public patrons with lastname, firstname, date, time, staffinitials, CPU number. I need a way to compare the last name of all entries to a second sheet containing names. Then highlight if they match. Any Ideas?
A simple COUNTIF() or MATCH() function should take care of this handily. Let's say that you want to highlight any last names in Sheet1 column A where that are found in Sheet2 column B.
First select Sheet1's column A with A1 as the ActiveCell. Next choose Home ► Conditional Formatting ► New Rule. When the New Formatting Rule dialog opens, choose the Use a formula to determine which cells to format option and supply =COUNTIF(Sheet2!$B:$B, $A1) for the Format values where this formula is true: text box. Click Format and choose a red Fill. Click OK to accept the formatting and then OK again to create the new rule.
The last names in Sheet1's column A that have matches in Sheet2's column B will be highlighted in red.
Alternate CF Rule formula: =ISNUMBER(MATCH($A1, Sheet2!$B:$B, 0))
Conditional Formatting -- Introduction (Contextures.com)

Format cell color based on value in another sheet and cell

I have a workbook with two sheets. I would like to format the cell background color in the first column of sheet 1 based on the values in the second column of sheet 2.
For example, if the value of of sheet2, row 6, column 2 is say, 4, then I would like the background color of sheet 1, row 4, column 1 to be green. If none of the values in sheet 2, column 2 reference a particlar row in sheet 1, I'd like to leave it set to no color. There's no prohibition against the same value appearing multiple times in the second column of sheet 2. Bonus kudos if you can tell me how to unset the color if the last value in sheet 2 pointing to a row in sheet 1 is removed.
I'm sure that for the Excel wizards out there this could be trivial, but I rarely have occasion to use excel and certainly don't have time to become a black belt in it. Can anyone offer me advice, pointers, or a quick formula to do this? If this is going to take some complex VB code to implement, it isn't worth it.
Thank you!
You can also do this with named ranges so you don't have to copy the cells from Sheet1 to Sheet2:
Define a named range, say Sheet1Vals for the column that has the values on which you want to base your condition. You can define a new named range by using the Insert\Name\Define... menu item. Type in your name, then use the cell browser in the Refers to box to select the cells you want in the range. If the range will change over time (add or remove rows) you can use this formula instead of selecting the cells explicitly:
=OFFSET('SheetName'!$COL$ROW,0,0,COUNTA('SheetName'!$COL:$COL)).
Add a -1 before the last ) if the column has a header row.
Define a named range, say Sheet2Vals for the column that has the values you want to conditionally format.
Use the Conditional Formatting dialog to create your conditions. Specify Formula Is in the dropdown, then put this for the formula:
=INDEX(Sheet1Vals, MATCH([FirstCellInRange],Sheet2Vals))=[Condition]
where [FirstCellInRange] is the address of the cell you want to format and [Condition] is the value your checking.
For example, if my conditions in Sheet1 have the values of 1, 2 and 3 and the column I'm formatting is column B in Sheet2 then my conditional formats would be something like:
=INDEX(Sheet1Vals, MATCH(B1,Sheet2Vals))=1
=INDEX(Sheet1Vals, MATCH(B1,Sheet2Vals))=2
=INDEX(Sheet1Vals, MATCH(B1,Sheet2Vals))=3
You can then use the format painter to copy these formats to the rest of the cells.
Here's how I did it in Excel 2003 using conditional formatting.
To apply conditional formatting to Sheet1 using values from Sheet2, you need to mirror the values into Sheet1.
Creating a mirror of Sheet2, column B in Sheet 1
Go to Sheet1.
Insert a new column by right-clicking column A's header and selecting "Insert".
Enter the following formula into A1:
=IF(ISBLANK(Sheet2!B1),"",Sheet2!B1)
Copy A1 by right-clicking it and selecting "Copy".
Paste the formula into column A by right-clicking its header and selecting "Paste".
Sheet1, column A should now exactly mirror the values in Sheet2, column B.
(Note: if you don't like it in column A, it works just as well to have it in column Z or anywhere else.)
Applying the conditional formatting
Stay on Sheet1.
Select column B by left-clicking its header.
Select the menu item Format > Conditional Formatting...
Change Condition 1 to "Formula is" and enter this formula:
=MATCH(B1,$A:$A,0)
Click the Format... button and select a green background.
You should now see the green background applied to the matching cells in Sheet1.
Hiding the mirror column
Stay on Sheet1.
Right-click the header on column A and select "Hide".
This should automatically update Sheet1 whenever anything in Sheet2 is changed.
I'm using Excel 2003 -
The problem with using conditional formatting here is that you can't reference another worksheet or workbook in your conditions. What you can to do is set some column on sheet 1 equal to the appropriate column on sheet 2 (in your example =Sheet2!B6). I used Column F in my example below. Then you can use conditional formatting. Select the cell at Sheet 1, row , column 1 and then go to the conditional formatting menu. Choose "Formula Is" from the drop down and set the condition to "=$F$6=4". Click on the format button and then choose the Patterns tab. Choose the color you want and you're done.
You can use the format painter tool to apply conditional formatting to other cells, but be aware that by default Excel uses absolute references in the conditions. If you want them to be relative you'll need to remove the dollar signs from the condition.
You can have up to 3 conditions applied to a cell (use the add >> button at the bottom of the Conditional formatting dialog) so if the last row is fixed (for example, you know that it will always be row 10) you can use it as a condition to set the background color to none. Assuming that the last value you care about is in row 10 then (still assuming that you've set column F on sheet1 to the corresponding cells on sheet 2) then set the 1st condition to Formula Is =$F$10="" and the pattern to None. Make it the first condition and it will override any following conflicting statements.
Here is my own solution for restoring the original colors when copying certain highly formatted sheets or templates to a new spreadsheet.. it copies all data directly, so it only works if you need to copy a sheet, not only apply colors to a different sheet with different data:
copy the original format workbook by ctrl + g and selecting the appropriate range
paste it into the new work sheet, colors will be all changed
with the destination still highlighted, right click and go to "Paste special" and select "All using source theme", then repeat the paste special, only with "Values" this time, and it should be identical to the original sheet you copied
I've done this before with conditional formatting. It's a great way to visually inspect the cells in a workbook and spot the outliers in your data.

Resources