VLOOKUP based conditional formatting highlights the cell above the intended one - excel

I'm trying to apply conditional formatting to a column in Excel using the "Use a formula to determine which cells to format" feature.
In Sheet 1 have a list of names in column A with corresponding reference numbers in column B. In Sheet 2 I have a longer list of reference numbers in column C. I want the conditional formatting rule to look up the reference numbers in Sheet 1 against those in the Sheet 2 and highlight the cell where they is an overlap.
I have found an apparent solution to this using a vlookup as the formula:
=$B2=VLOOKUP($B2,Sheet2!$C:$C,1,FALSE)
This works in that cells in Sheet 1 have the correct formatting applied, but all the cells have been shifted up by one (image). I have copied the highlighted reference numbers out and done a lookup against the reference numbers in sheet 2 to double-check and the top one highlighted isn't in Sheet 2 but the one below the filled cells is (image).
I have tried replacing the vlookup in the conditional formatting with an INDEX/MATCH function in case there was a problem with the VLOOKUP but the result was the same: =$B2=INDEX(Sheet2!$C:$C,MATCH($B2,Sheet2!$C:$C,0))
I've tried removing the spaces between the xx and numbers in the references based on a different stackoverflow answer, but no luck. I've also tried changing the format of the cells from General to Text with the same result.
Any ideas would be appreciated!

You created this on the entire column B so the Applies to: is B:B. The formula references B2 but it is relatively referenced to B1. The highlights will always be applied to the cell one row below. Here are some solutions:
Change the Applies to: to =$B$2:INDEX($B:$B, MATCH("zzz", $A:$A)). This will resolve to the correct range and will not stay as a formula. You will need to have a look at the formula after you apply this to ensure that hte xlA1 references have not adjusted to teh new range.
Change the formula to ignore the first row. e.g. =AND(ROW()>1, ISNUMBER(MATCH($B1, SHeet2!$C:$C, 0))). No further adjustment should be necessary and the fuill column Applies to: is valid..

This should do the trick. Both the vlookup and the index match are throwing an error. Wrapping it in the iferror function should fix that.
=$B2=iferror(VLOOKUP($B2,Sheet2!$C:$C,1,FALSE),0)

Related

How to define excel SUMIFS criteria considering any text and numbers?

My SUMIFS formula criteria is based on a cell (say A1) that is data validated by list and changed via selection by user. If cell has data inside text or number by selection from drop down list, SUMIFS formula is considering that data as criteria to calculate the related sum. If criteria cell is left blank, I want formula to sum everything without any condition. My problem here; in criteria field of SUMIFS formula, I typed if condition like; SUMIFS(sum-range,criteria_range,IF(A1<>"",A1,"*")) but in this case excel considers only text values and do not include cells containing number. Briefly, if nothing selected in A1, I want SUMIFS formula to sum everything without any condition, numbers, texts and even blank cells. How can we proceed to do that?
EDIT:
Here an example for data and formula, what is expected is actually to disable criteria if one of selection is blank on left. Harun's suggestion works but if there is blank cell in criteria range, then in this case it won't consider those values in sum. For instance, if we select from left Phone/smart/touch, then how can we get "2" as output no matter what is in cri_range4 cells? Thanks
Example:
How about this solution? It basically ignores a missing entry in column C and evaluates only the other two. (Your example formula has a fourth criterium that isn't apparent in your list but the method can be extended for as many criteria as you might have.
=SUMPRODUCT((IF(LEN(C2),(INDEX(Lists,,1)=C2),TRUE))*(IF(LEN(C3),(INDEX(Lists,,2)=C3),TRUE))*(IF(LEN(C4),(INDEX(Lists,,3)=C4),TRUE))*SumRange)
For better readability I created a named range Lists which comprises your sample range E2:H10 while I named I2:I10 as SumRange'. INDEX(Lists,,1}` refers to the first column of the range. It's important that SumRange and Lists have the same number of rows.
If A1 is blank then just use not equal operator to sum all cells that are not blank. Try below.
=SUMIFS(D1:D5,C1:C5,IF(A1<>"",A1,"<>"))
Edit: can you check below formula in D3 cell then drag down.
=IF(C2="",SUM($I$2:$I$10),SUMPRODUCT(($E$2:$H$10=C2)*($I$2:$I$10)))

With Excel Conditional Formatting - Want to Highlight Cells in a range that match any from another range of cells

Sheet One has 5 cells in a row with numbers. (A2:F2)
Sheet Two also has 5 cells in a row with numbers. (A3:F3)
I'd like to highlight sheet one's cells yellow every time that sheet two has a matching number entered. (There will be more rows of data added to each sheet, but I am using the first row only, to keep it simple.
It works with creating a CF equals to, but I need something that applies to a range of data, from a range of data to make this less tedious. Thank you for any tips!
I am using conditional formatting. I have tried Vlookup, Match, and Countif, but I am new to this type of formatting.
(Sheet two's numbers can be placed in a list (column), instead of a row, if that matters)
I'd suggest using COUNTIF:
=COUNTIF(Sheet2!$A:$F,A2)>0
Snapshot of Sheet1 and the Conditional Formatting:
Snapshot of Sheet2:

Conditional Formatting If any cell In a column Matches any other Cell in another

I am trying to highlight cells in a column in Excel that match a list of values in another column. Everything i have found so far like =NOT(ISERROR(MATCH(A1,$B$1:$B$1000,0))) only highlights the cell next to one that matches not the actual matching Values.
Basically i am tryingto highlight every value in column B:B that matches any entry in A:A.
You just about had it right.
Try this instead:
=NOT(ISERROR(MATCH(B1,$A$1:$A$5,0)))
Or in R1C1 mode (which, IMHO, is much easier to work in as the formula doesn't change regardless which cell in column 2 you're on):
=NOT(ISERROR(MATCH(RC,R1C1:R5C1,0)))

Filling down a VLOOKUP formula without changing the range

I am comparing values in a row in one sheet to values in another row in another sheet. The following formula and works:
=IFERROR(VLOOKUP(A1,Sheet1!A1:A19240,1,FALSE),"No Match")
My problem is when I fill down the formula, it increments A1 correctly but also increments the (A1:A19240), so half way down I have narrowed the search field.
How can I apply this formula to a column?
Change A1:A19240 to A$1:A$19240, i.e. apply:
=IFERROR(VLOOKUP(A1,Sheet1!A$1:A$19240,1,FALSE),"No Match")
This is called using absolute references.

(Excel) Conditional Formatting based on Adjacent Cell Value

I'm trying to apply conditional formatting in Excel on a range of cells, based on the adjacent cell's value, to achieve something like this:
The goal is to highlight values in Column B (Actual Expense) red if the value is greater than it's adjacent value in column C (Expected Expense). I've followed a number of tutorials that said to apply conditional formatting by selecting Conditional Formatting>New Rules>Use a Formula to Determine Which Cells to Format then applying a rule =$B4>$C4 which would format the 'Actual' cell red if it were greater than the 'Expected' cell. This works great for one cell, but not so well when I attempt to apply this to a range of cells. I've used the format painter as well as editing the rule to be applied over a range of cells (i.e. $B$2:$B$5) as shown below but it only bases the formatting on the initial formula (if B4 is greater than C4) and everything undesirably turns red.
I'd rather not make individual rules for every row. Is there a way to consolidate this into one rule?
You need to take out the $ signs before the row numbers in the formula....and the row number used in the formula should correspond to the first row of data, so if you are applying this to the ("applies to") range $B$2:$B$5 it must be this formula
=$B2>$C2
by using that "relative" version rather than your "absolute" one Excel (implicitly) adjusts the formula for each row in the range, as if you were copying the formula down
I don't know if maybe it's a difference in Excel version but this question is 6 years old and the accepted answer didn't help me so this is what I figured out:
Under Conditional Formatting > Manage Rules:
Make a new rule with "Use a formula to determine which cells to format"
Make your rule, but put a dollar sign only in front of the letter: $A2<$B2
Under "Applies to", Manually select the second column (It would not work for me if I changed the value in the box, it just kept snapping back to what was already there), so it looks like $B$2:$B$100 (assuming you have 100 rows)
This worked for me in Excel 2016.

Resources