Conditional Formatting using vlookup - excel

I have Sheet 1 as
AssocNum RatePlanCde RateType RateTypeDesc
272 911 2 Adjustable
472 1115 2 Fixed
Many of these RatePlanCde are not valid anymore. These have been highlighted in red in Sheet 1. For example, 911 is not a valid RatePlanCde, while RatePlanCde 1115 is still valid.
I have sheet 2 as
AssocNumEID RateCostComponentCde RatePlanCde ReadOnlyInd
272 2 911 Null
472 4 1 Null
I need to find the rows in Sheet 2 where the RatePlanCde is invalid and highlight those rows. Any help in doing this using conditional formatting with VLOOKUP will be appreciated.
UPDATE:
Updating to add more details.
I tried the COUNTIFS solution proposed here but for some reason it is not working for me. What am I missing?
I have added a helper column to Column B of Sheet1 (aka RatePlan) that includes either Valid or Invalid for the corresponding RatePlanCde column (Column C).
I am using this formula under conditional formatting in Sheet 2 for conditional formatting:
=COUNTIFS(RatePlan!$B$2:$B$2514,"Invalid",RatePlan!$C$2:$C$2514,$C2)>0

I realize your answer was looking for a solution using VLOOKUP, but I think a cleaner method would be to use a COUNTIFS formula.
As mentioned by #drewster, you'll first need to add a helper column to Sheet1. I placed mine in Sheet1!Column A so that it's out of the way of the user and less likely to be corrupted in any way, especially after hiding it, but you can place yours in any convenient column.
There is no formula in Sheet1!Column A, only hardcoded values (which you'll need to enter).
Helper column added to Sheet1
Then on Sheet2 you need to add a conditional formatting rule using the Use a formula to determine which cells to format rule. In the formula box under where it says, Edit the Rule Description, your formula will be:
=COUNTIFS(Sheet1!$A$2:$A$100,"Invalid",Sheet1!$C$2:$C$100,$C2)>0
The ranges I used in the formula - Sheet1!$A$2:$A$100 & Sheet1!$C$2:$C$100 - should cover your entire "table" of information on Sheet1, so adjust those as needed. $C2 is the first cell on the conditionally formatted sheet that you are attempting to match to Sheet1!$C$2:$C$100.
Also, make sure your rule Applies to your entire "table" of information on Sheet2 (my example uses range =$A$2:$D$101, so feel free to change that as well).
Conditional Formatting Rules Manager for Sheet2
Conditional formatting applied to Sheet2
After all of this, you should get your desired result.

Related

How to highlight cells with duplicate values using Excel's inbuilt Conditional Formatting rules, specifically to compare < or >?

OS: Windows 10 Pro Version 20H2 (OS Build: 19042.1165)
Application: Microsoft Excel for Microsoft 365 Version 2107 (Build 14228.20250)
***Please bear with me for posting a non-code-related question. I posted this question on SU and I sincerely appreciate the members who gave their answers but I just couldn't get a satisfactory answer there. If moderators decided to close this post, you may follow this link to my post at SU.
When using Excel's inbuilt Conditional Formatting rules to highlight cells with duplicate values, specifically to compare < or >, it doesn't seem to work on my end.
I tried searching the internet about this issue to no avail.
Using the table below to visualize an Excel spreadsheet,
Value
Value
<
<
>
>
I highlighted cells A1:B3, clicked on Home Tab>Conditional Formatting>Highlight Cells Rules>Duplicate Values…,>OK. Regardless if I choose Duplicate or Unique on the dropdown options, it just won't work here. Only the first row is being formatted.
It works fine though when using conditional formatting formula.
I'd like to know, with your help, if this issue is isolated, or am I just missing something here? Could it be a bug?
Thank you all very much..
One way to highlight duplicate rows in a multi-column array, change the rule type to "Use a formula to determine which cells to format" and enter this formula:
=$A1=$B1
$ tells the formula to always reference columns "A" and "B"
Because there is no $ before the row number, it becomes dynamic and the condition is applied to each row in the array it applies to.
The conditional Formatting is performing as it is designed to function.
The reason selecting the duplicate conditional formatting option does not highlight rows where the columns match is because it is not looking at each row in the array separately, it is looking at the entire data set to see if there are duplicated values. So if you have a value in more then one cell (any row or column), it will highlight all cells with multiple values.
A B
1 a b A1 will be highlighted
2 c a A2 and B2 will be highlighted
3 d c B3 will be highlighted

Using IF and conditional formatting

I'm trying to have a cell becoming highlighted if it satisfies two criteria.
I would like the cells below each Staff column to be purple if its both the same as the version# and contains *.
I've managed to highlight cells containing the * by using "highlight if cells contain" ~* but I can't get it to do both.
I've tried
=AND(L2=$J2,"~*")
=AND($J2,"~*")
=IF(AND(L2=$J2,"~*"))
(Version# is column J, Staff 1 is column L)
Answer by BigBen
If the Staff # contains an asterisk, will it always immediately follow the version #? If so you could just do
=L2=$J2&"*"
Seeing what I think you want, the main issue is the asterisk. When you enter a number in a cell and also enter a non-numerical character the cell automatically becomes formatted as TEXT. It is possible to extract the numerical value with a formula, but handling what you want is much easier if you separate the number from the asterisk. In my included example (You should be able to open it in a new tab on your browser) created narrow columns after each 'staff#' column to accept the asterisk entry.
This done, enter the three conditional formats as shown (in C2 in the example). You then copy the C2 cell into each of the cells under the Staff# columns. That produced the results shown which I think is what you want. Changing entries will produce the proper formatting results for that cell.

Conditional formatting formula to highlight/color an entire row based on two different column values

I have searched far and wide but cannot seem to find a question that answers this.
I am trying to highlight/color an entire row in Microsoft Excel for Mac (16.33) based on two different values in two different columns.
This is my current forumla:
=AND(SEARCH("no",INDIRECT("C"&ROW())),SEARCH("yes",INDIRECT("D"&ROW())))
From my understanding, it is searching first in column C for "No", then proceeding to search column D for "yes". Enclosing this in AND() must ensure that both cases are true. If they are not, it returns false and does not apply the formatting.
This formula should return something like this, which works perfectly with the above example in Google Sheets:
Column D contains a yes, but Column C also contains a no, rendering the entire row yellow.
Since conditional formatting works top to bottom, it moves on to the next rule which is:
=SEARCH("yes",INDIRECT("D"&ROW()))
Hence, two "yes" return full green across the row.
I cannot get this to work in Excel with the same exact formulas. I have ensured the correct cell range has been selected for conditional formatting.
Why is such a complex formula needed? The following must work in Excel:
=($C1="N")*($D1="Y") - for yellow
=($C1="Y")*($D1="Y") - for green
Don't know about GoogleSheets

How to set the background of three cells based off of the value in one other cell, relatively?

I'm trying to make a formula that will color code three cells that are directly above/below each other. The color coding depends on the sum of three other cells that are directly above/below each other, and directly across from the cells to be colored.
This part is easy. The rule is:
Forumula: =SUM(H5:H7)>30
And it applies to:
$E$5:$E$7
However, the issue is that when I copy the cells that are being colored (E's) to three more cells below them for the next batch, the relative formula does not work as expected. It applies the formula on H6:H8 (+1) instead of H8:H10 (+3).
Is there a way to get the relativeformula to work as expected? I hope this was clear enough. I know it's hard to visual a spreadsheet, but ultimately I need the relative forumla to add +3 instead of +1 when it is copied.
Problem:
If I correctly understand, what you are trying to achieve is to have the range E5:E7 formatted strictly based upon H5:H7, then the next three-cell range - E8:E10 - based upon H8:H10 and so on. You can do this by implementing the below solution:
Solution:
Step 1: Setup Columns as Below
Step 2: Implement Conditional Formatting as Below
Explanation:
I have recreated your issue and I see your problem; it was not that obvious until I played around with changing values of different cells in Column H.
Apparently, this has to do with how Excel interprets your instructions (formula) supplied under conditional formatting. To understand this let's first focus on the behavior of cells E5, E6 and E7 as a function of values in Column H.
With the formula =SUM(H5:H7)>30 did you notice that:
E5 format depends upon =SUM(H5:H7),
E6 format depends upon =SUM(H6:H8), and
E7 format depends upon =SUM(H7:H9) and
when you copy the range E5:E7 three cells down into E8:E10, the expected behavior is:
E8 format depends upon =SUM(H8:H10),
E9 format depends upon =SUM(H9:H11), and
E10 format depends upon =SUM(H10:H12)
And this is exactly how the range E8:E10 will behave once the above solution is applied.
A partial answer to your question has to do with your relative formula - =SUM(H5:H7) - under conditional formatting. Using this formula causes $E$5 to use =SUM(H5:H7) to determine its formatting, $E$6 to use =SUM(H6:H8) to determine its formatting, and so on. This ultimately leads to issues with the conditional formatting even before you begin copying the cells down.
EDIT: (piggy-backing off #Bharat Anand's answer)
#Bharat Anand's answer appears to be the best way to accomplish this question.
#Thisisstackoverflow requested clarification (under the accepted answer) and I'm hoping my screenshot below will help.
I set my worksheet up in what I believe is the exact same manner as #Bharat Anand, and it seems that the column letters may have been off. Setting mine up like this made it work correctly.
EDIT: (clarification for future visitors)
I really liked #Bharat Anand's solution, so I wanted to explain how it works (using the images/formulas in the solution as reference):
The calculation in Column I is setup to return a number that will only appear three times, in succession, in Column I; in this way it kind of behaves like a unique identifier, allowing other formulas to reference these values for calculation purposes.
Three times is key for the original poster because they were looking for a range of three cells to be formatted based on a sum of three cells. For example, the formula in Column I can be modified to
=ROUNDDOWN((ROW()-b)/a,0)
where:
a is your desired number of cells to format/sum, and
b is equal to a - 1.
Using the formula in J5 as an example, this SUMIF formula uses I3:I7, which includes two (or b, as setup in my explanation above) rows above and two (b) rows below to decide if I5 equals any of the values found in I3:I7. It's important to include the two rows above and two rows below so that the range overlaps the same three cells to meet the requested requirements.
When I5 finds a match, the formula looks to Column H to sum those rows in H3:H7 where I3:I7 equals I5. In this example, J5, J6, and J7 will each equal 32.
Using the simple conditional formatting formula that was setup, we know that cells in Column E should be highlighted when the corresponding row in Column H is greater than 30. According to the original question, this should be done in ranges that are three (a) rows tall. We already handled for that, so all that was left was to make sure the conditional formatting spanned the data area in Column E.
I'm hoping I don't confuse and/offend anyone with this explanation, but it's how I understand it. I like the proposed solution and explaining it to myself again helps me solidify how it works.

Excel Conditional Formating only formatting top cell in range

I am trying to use conditional formatting to highlight which of the cells in a row are today's date. I am using the formula:
=G2=(TODAY()) and the range is Sheet1!$G$2:$G$10.
However only the first cell in a column is highlighted even when the same date is listed below.
On a very similar formatting formula (=E2="High" on the range E2:E10) the formula seems to work a treat! I can't work out why there is a difference.
Thanks,
Alex
Please try:
=G2=TODAY()
(but only because one set of parentheses is not required!) and for Applies to:
=$G$2:$G$10
The Applies to range has to be in the same sheet as is G2 in your formula.
I suspect if you go back to the Conditional Formatting Rules Manager you will see that what you entered was automatially removed (substituted by =$G$2, hence the one cell that 'works').

Resources