Set conditional formatting to compare content to cells in different sheet - excel

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)

Related

Excel Lookup between multiple columns

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.

Conditional Excel formatting based on another cells value

I want to take a cell and format it based on the value of another cell. For example
I want to from A23 based on the value of C23 but when I select A23 and ass this formula it only formats D23. Also is there a way to duplicated this easily for 29 other rows? A22/D22 for example.
="D23<1%"
Select all of the cells you want to apply the conditional formatting rule to with the cell in the top-left as the active cell. Note the row of this cell. For the sake of argument, I'll say this is row 22.
Clear out the previous attempts at a conditional formatting rule and start a new one. Choose Use a formula to determine which cells to format then supply the following in the Format values where this formula is true: text box.
=$D22<0.01
Note that I've used row 22 in this formula. That should be changed to whatever row your block of cells to receive the CF rule starts with.
Click Format and select some formatting. Click OK to confirm the formatting choices and then OK again to create the new rule.

Excel: Highlighting a whole column depending on date

I have made my own Gantt chart in Excel, which is shown in this picture:
.
I would like to highlight the whole column (or until the last activity) depending on the date, as shown in the picture. I figured out how to highlight a single cell depending on the date, but not a whole column.
I don't know how to do it short of entering the date into the whole column, but I thought there would be something more efficient if conditional formatting is used.
If you'd like an entire range to conditionally format based on the value of one of the fields in the range, use an absolute cell reference. I couldn't figure out perfectly from your picture which cell contains the date, but I'll try to give you an example.
If you have dates in the Cells in Row 1, and you want to highlight the entire column when the row has today's date, the conditional format formula would look like below. (Assuming today's date is in cell C1, then the entire column from C1:C25 [the range upon which I applied the conditional format] will be highlighted).
Steps:
Highlight the entire range upon which you want to apply the formatting. In my example, I'm using range A1:H25
In the Excel Ribbon, select Home > Conditional Formatting > New Rule...
On Windows, select Use a formula to determine which cells to format. On macOS, first choose Classic from the Style dropdown menu and then from the second dropdown menu, pick Use a formula to determine which cells to format.
The formula will be =A$1=TODAY() [NOTE: We check cell A1 first because it is the first cell in our highlighted range. We choose $1 because the dates are always in Row 1. Change that to suit.]
Select the format you'd like to apply
To test out how it looks, press OK

Conditional formatting using list from another sheet

I have a spreadsheet for work with a list of claims from the previous month. Column A on Sheet1 contains the employer's alphanumeric group# (A2-A501).
Sheet2 contains just a list (A1-A46) of group#'s that don't need review, and I'd like to set a conditional rule so that any row on Sheet1 where the value in the A column matches any of the group#'s in Sheet2, then the entire row formats appropriately to what I set (in this case, highlights red).
I researched online, but couldn't find any that would fit my specific scenario that also worked.
Seems:
=MATCH($A2,vRange,0)
as a Conditional Formatting formula rule suited, where vRange is the name of Workbook scope given to the relevant range in Sheet2.
Select the entire selection you want the formatting to apply to.
Open the conditional formatting menu.
Select "Use a formula to determine which cells to format"
Set your format (fill red)
Enter the following formula
=NOT(ISERROR(VLOOKUP($A1,Sheet2!$A:$A,1,0)))
This assumes that on Sheet2, your group#s that don't need review are in column A.

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