Conditional Formatting using multiple vlookups - excel

I have an excel spreadsheet and I am trying to do conditional formatting based on multiple conditions. I have to highlight the rows where (Column A value matches column C) AND (Column B matches column D). I tried 3 ways but none of them are giving me expected results-
Method 1 - I tried conditional formatting with these 2 Rules-
(VLOOKUP($A2,C2:C93,1,FALSE))>0
(VLOOKUP($B2,D2:D93,1,FALSE))>0
and applied it to $A$2:$D$5745
but this is not working as expected.
Method 2- I tried using if but this is also not providing me desired results
=if(VLOOKUP(A2,$C2:$C93,1,FALSE)>0 & VLOOKUP(B2,$D2:$D93,1,FALSE),True,False)>0
applied it to $A$2:$D$5745
Method 3- =AND((VLOOKUP($A2,C2:C93,1,FALSE))>0,(VLOOKUP($B2,D2:D93,1,FALSE))>0)
applied it to $A$2:$D$5745
To rephrase this problem- I would like to highlight all rows where CustEID in Col A and Account EID in cloumn B match CustEID in col C and Account EID in col D.
Can someone please guide me?

Here's what I was able to get working.
The VLOOKUP evaluates to return either the "found" value or #N/A. By modifying your formula with a logical check >0, this converts the result to a boolean value (TRUE) but only in the case where VLOOKUP is returning a valid value. In many of your cases, your formula still evaluates to #N/A.
So this: =VLOOKUP(A2,$C$2:$C$93,1,FALSE)>0 will return either TRUE or #N/A.
I've modified the formula to =IFNA(VLOOKUP(A2,$C$2:$C$93,1,FALSE)>0,FALSE), which forces the entire formula to return a true boolean value TRUE or FALSE.
The cell range references in your formulas need to be locked into specific ranges that will not be evaluated as "relative" in the context of the conditional format formula. So your formula VLOOKUP($A2,C2:C93,1,FALSE) using the range C2:C93 will also "slide" (my own terminology for this formula going "relative") as it progresses down the rows. So each of your formulas needs to lock this down with VLOOKUP($A2,$C$2:$C$93,1,FALSE).
Notice that the only portion of the formula that stays relative is the row number -- the 2 in this case. So you'll start your conditional format setup on row 2.
Combining these formulas for the full test you want to apply gets you
=AND(IFNA(VLOOKUP($A2,$C$2:$C$93,1,FALSE)>0,FALSE),IFNA(VLOOKUP($B2,$D$2:$D$93,1,FALSE)>0,FALSE))
Applying this to your conditional format as a full row requires one last adjustment. Instead of applying your rule to the range $A$2:$D$5745, you have to remove the column references. So the application range becomes $2:$5745.
This is what I get when it's all put together:

Related

check multiple cells value in a sorted list have same value as another manual cell

How to write a formula in excel that based on critria it can check if list of multiple result cells have same value.
I attached example:
Look for all cell with the number 100
Verify that the list of these cells contain same date value of one cell.
I try to use formula such as: COUNTIF + INDEX and MATCH but didn't work as expacted.
I'm guessing you can use =ROWS(FILTER(....)) but what I would do is create a hidden column that evaluates it per row, maybe with something like
=IF(A2="","",XLOOKUP(A2,A$2:A,B$2:B)=B2)
and copy that formula down the column.
This way, you can not only see if there are any bad values (by COUNTIFS for false values where the A-column's value matches the "find these cells" value) but apply conditional formatting as well to highlight the bad values.

Validation by Using CONCAT in COUNTIF

I want to concatenate the value of two columns in the current sheet and then result should be compared with the concatenation of two column value in another sheet.
e.g - The entered value in Column W and X in current sheet after concatenation should be compared with the existing value in column Y and column Z(after concat) of another sheet.
I have tried using the formula COUNTIF(Sheet2!CONCAT($W$2,$X$2:$Y$2,$Z$2),A2)>0 and some different alteration in this but it seems COUNTIF has range and criteria as argument and this is string which is causing error.
If you want to compare, a simple '=' will do.
Concatenation can be done using '&'.
in current sheet:
=W1&X1=Sheet2!Y1&Sheet2!Z1
will return TRUE if both concatenations are equal and FALSE if they are not.
To find the value W1&X1 in the entire range, I suggest you use a help column (unless you are willing to write a macro). In the help column of sheet1, you concatenate the values (=W1&X1 - drag down). In the hlep column of sheet2 you do the same. Then you make an additional column to check for matches, by using
=match(ValueHelpColSheet1,HelpColSheet2,0)
This formula returns the row number in which the match is found and an error when the corresponding value is not found. You can replace this error with something else using IFERROR if you want to.

Replicating conditional formatting in Excel

I'm having trouble using Conditional Formatting in Excel. No problem with setup for one row, but no luck replicating it to the rest of the worksheet.
A B C D
1 MATCH_RESULT CODE DESCRIPTION CHECKUP
2 #N/A A1 Chair #N/A
3 #N/A B1 Window #N/A
4 2 C1 Table #N/A
The goal is to identify if column A is filled with value #N/A (default error message for MATCH function). If it is, cells in columns - A, B, C - ONLY ON THE SAME ROW should be formatted (with color red). I.e. as per example, A2:C3 should be formatted.
This is working for me, however just for the first row and I fail to correctly replicate this downwards.
I'm selecting A2:C2 -> Conditional Formatting -> New Rule -> Use a formula to determine which cells to format.
I will end up with the formatting setup such as:
Formula: =$A$2=$D$2
Applies to: =$A$2:$C$2
A2 through C2 will be formatted, as expected (due to A2=D2). However I can't replicate the same thing on next rows. Format painter function will expand the current functionality so that still A2=D2 match is looked at for formatting other rows, instead of A3=D3 and so on.
Pretty sure the key is in $, but nothing has worked yet. Also pretty sure Excel allows just one cell in column D to be populated with value #N/A for comparison.
You have three issues, first your range is (part of) a single row =$A$2:$C$2. Try selecting ColumnsA:C before adding the rule, or change Applies to to:
=$A:$C
Second, you have anchored the row references in your formula. The 'style' should be:
=$A1=$D1
However your third issue is that comparing errors (#N/A resulting from a function) returns ... #N/A (so I don't know how you managed to get even a single row to work, since CF needs a TRUE result to trigger).
Maybe try:
=AND(ISNA($A1),ISNA($D1))
Replace the formula part with
=iserror($A2)
you may need to remove the $ manually.

Excel Conditional Formatting, Referencing 2 cells to the Right with conditions

I have a list of students who are between the ages of 3 and 5. lets say column A has the code, Column D has the childs age & Column F has their age group (3-5) If their age exceeds the age group then the Cell in column A will highlight Red. I am just not sure how to write this code correctly, all of the combinations i have tried come up with an error or just don't do anything.
IF(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5" & (OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5 {THEN FILL CELL RED} {ELSE NO FILL}
In the first part of the statement you are checking whether the cell 7 columns across = "3-5". You don't need to use offset for this, you can just reference the cell 7 across directly.
So if you're applying the conditional formatting to A1 that part of the formula would just be =IF(H1="3-5",{then},{else}).
If you just want TRUE or FALSE as the answer you don't need the IF statement, so this shortens to: =H1="3-5",
If you're applying the conditional formatting to a range instead of just an individual cell, say A1:B10, then you write the formula for the cell in the top left of the that range. So for A1:B10 you would still you the same formulae as above.
For the second part of the statement, using the same logic as above, you get: =E1>5
To check both statements together you need to wrap them in the =AND() function, giving you this as the final formula for your conditional formatting:
=AND(H1="3-5",E1>5)
By using the AND function I can achieve the desired result without cell references moving if a cell is relocated.
=AND(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5yo",OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5)

Excel formula to return a value from a range where conditional statements are true

I've searched for an answer for this for awhile now but haven't had any luck. It's a bit difficult to put into words, so please let me know if anything's unclear.
What I want is a way to perform conditional statements on two columns. When both conditions are true, I want to return the value from a third column that is in the same row as where these conditions were met. So if the conditions are true in D5 and C5, I want to return the value from Q5 into the cell with the formula. The conditional statements are easy enough but I haven't figured out the last step yet.
If I use the following formula, I get 1 in the cell with the formula, which is right.
=IF(AND('Stata Output'!D2:D6='Backcheck schedule and results'!C2, 'Stata Output'!C2:C6=1),1,0)
However, replacing 1 in the formula with the range of cells that I want to pull the value from gives me a zero every time, which I know is wrong. For this latter formula I'm using:
=IF(AND('Stata Output'!D2:D6='Backcheck schedule and results'!C2, 'Stata Output'!C2:C6=1),'Stata Output'!Q2:Q5,0)
Any ideas on where I'm messing up?
Thanks!
Give this a shot - I'm sure there is a simpler way but it seems to get the job done (make sure to enter as an array formula with Control+Shift+Enter):
=INDEX('Stata Output'!$D$2:$Q$6,MATCH(1,(--('Stata Output'!$C$2:$C$6=1)*--('Stata Output'!$D$2:$D$6="Backcheck schedule and results")),0),14)
What this does is take your entire table as the range (first argument to INDEX, then uses MATCH to find the row where both of your conditions are met (in this case, column C must be 1 and the corresponding value in column D must be Backcheck schedule and results). You then search the resulting array for 1 (which indicates the match) and return column 14 (which represents column Q in our table). You can continue to add filters inside the MATCH() function as needed.
Note that this will match only the first 'hit'.
Looks like AND isn't working correctly in array formulas, so I would use this:
=IF(('Stata Output'!D2:D6='Backcheck schedule and results'!C2)*('Stata Output'!C2:C6=1)=1,'Stata Output'!Q2:Q5,0)
This will give you a new results column, that will be filled from the Q2:Q6 column for every matching row.
To use it, you should select all of the results column, input the formula and then use CTRL+SHIFT+ENTER.
Just make sure to use use ranges of the same size.
Try the following formula:
=LOOKUP(2,1/('Stata Output'!D2:D6='Backcheck schedule and results'!C2)/('Stata Output'!C2:C6=1),'Stata Output'!Q2:Q5)
If there is more than one row where both conditions are satisfied, this formula will return the col Q value from the last of those.

Resources