SOLVED
Home

Conditional Formatting doesn't work correctly with Data Validation

%3CLINGO-SUB%20id%3D%22lingo-sub-835844%22%20slang%3D%22en-US%22%3EConditional%20Formatting%20doesn't%20work%20correctly%20with%20Data%20Validation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-835844%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20facing%20an%20issue%20in%20Excel%202010%2C%20whereby%20if%20I%20try%20to%20apply%20Conditional%20Formatting%20on%20a%20selection%20that%20also%20contains%20cells%2Fcolumns%20with%20Data%20Validation%20applied%2C%20then%20it%20doesn't%20work%20as%20expected.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20apply%20Conditional%20Formatting%20to%20a%20worksheet%20such%20that%2C%20for%20all%20rows%20where%20the%20value%20of%20a%20particular%20column%20is%20%22Y%22%2C%20then%20the%20row%20is%20colored%20blue.%20Data%20Validation%20is%20applied%20in%20this%20column%20for%20possible%20values%20Y%2FN%2F%3CEM%3EBlank%3C%2FEM%3Eonly.%20I%20have%20tried%20to%20achieve%20this%20as%20under%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAn%20example%20worksheet%20is%20attached.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20Select%20all%20the%20columns%20with%20Data%20(Columns%20A%20thru%20N).%3C%2FP%3E%3CP%3E2.%20Home%20tab%20%26gt%3B%20Conditional%20Formatting%20%26gt%3B%20New%20Rule%20%26gt%3B%20option%20%22Use%20a%20formula%20to%20determine%20which%20cells%20to%20format%22.%3C%2FP%3E%3CP%3E3.%20Under%20%22Format%20values%20where%20this%20formula%20is%20true%22%2C%20enter%20%3CSTRONG%3E%3D%24K2%3D%22Y%22%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E4.%20Click%20Format%20button%20%26gt%3B%20Fill%20tab%20%26gt%3B%20select%20light%20blue%20color%20%26gt%3B%20OK%20(on%20format%20window)%20%26gt%3B%20OK%20(on%20New%20Formatting%20Rule%20window).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20has%20the%20effect%20of%20a%20number%20of%20rows%20getting%20colored%20light%20blue%20but%20they%20are%20seemingly%20random%20rows%2C%20and%20not%20ones%20where%20the%20value%20in%20column%20K%20is%20%22Y%22.%20I%20have%20googled%20this%20a%20lot%2C%20and%20almost%20all%20the%20articles%20confirm%20that%20I%20am%20using%20the%20right%20method.%20But%20I%20am%20not%20getting%20the%20desired%20results.%20Please%20help%20shed%20light%20on%20what%20is%20going%20wrong.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20%26amp%3B%20Regards%2C%3C%2FP%3E%3CP%3EBoyd%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-835844%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-835858%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20doesn't%20work%20correctly%20with%20Data%20Validation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-835858%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F402996%22%20target%3D%22_blank%22%3E%40lezboyd%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAttached%20please%20find%20the%20updated%20file%2C%20please%20let%20me%20know%20if%20it%20works%20for%20you%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-835874%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20doesn't%20work%20correctly%20with%20Data%20Validation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-835874%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F402996%22%20target%3D%22_blank%22%3E%40lezboyd%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20you%20select%20a%20range%20for%20conditional%20formatting%20and%20trying%20to%20create%20a%20new%20rule%20based%20on%20a%20formula%2C%20always%20pay%20attention%20to%20the%20row%23%20used%20in%20the%20formula%2C%20it%20must%20match%20the%20row%23%20of%20the%20first%20row%20in%20the%20selected%20range.%3C%2FP%3E%3CP%3ESo%20if%20you%20select%20the%20range%20A2%3AN103%20and%20create%20a%20new%20rule%20for%20conditional%20formatting%20using%20your%20formula%20for%20highlighting%20the%20rows%20where%20column%20K%20has%20a%20%22Y%22%20in%20it%2C%20it%20will%20correctly%20highlight%20the%20rows%20as%20the%20first%20row%20in%20the%20selected%20range%20A2%3AN103%20is%20row%232%20and%20the%20row%23%20of%20the%20cell%20you%20are%20referencing%20in%20your%20formula%20(%3D%24K2%3D%22Y%22)%20is%20also%20row%232%20and%20they%20both%20match.%3C%2FP%3E%3CP%3EBut%20if%20you%20select%20the%20whole%20columns%20A%3AN%2C%20the%20first%20row%20in%20the%20selected%20range%20will%20be%20row%231%20which%20doesn't%20match%20with%20the%20row%23%20used%20in%20your%20formula%20which%20is%20row%232%20hence%20the%20highlighted%20rows%20will%20be%20off%20by%20one%20row%20down.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20make%20sure%20that%20you%20don't%20have%20multiple%20conditional%20formatting%20rules%20for%20the%20same%20rule%20so%20it's%20always%20a%20best%20practice%20to%20select%20all%20the%20range%20once%20and%20not%20applying%20the%20conditional%20formatting%20to%20specific%20range%20and%20then%20using%20the%20format%20painter%20to%20copy%20the%20same%20conditional%20formatting%20to%20the%20other%20ranges%20otherwise%20you%20will%20end%20up%20with%20multiple%20conditional%20formatting%20rules.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20attached%2C%20I%20have%20applied%20the%20conditional%20formatting%20based%20on%20your%20formula%2C%20see%20if%20that%20works%20as%20desired.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-835892%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20doesn't%20work%20correctly%20with%20Data%20Validation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-835892%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20explanation.%20All%20the%20articles%20that%20I%20googled%20had%20examples%20that%20gave%20me%20the%20impression%20that%20the%20header%20row%20is%20to%20be%20ignored%20when%20entering%20the%20formula.%20Changing%20my%20formula%20to%20%3CSTRONG%3E%3D%24K%3CFONT%20color%3D%22%23FF0000%22%3E1%3C%2FFONT%3E%3D%22Y%22%3C%2FSTRONG%3Egave%20the%20expected%20results%20immediately.%20Thanks%20again.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-835930%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20doesn't%20work%20correctly%20with%20Data%20Validation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-835930%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F402996%22%20target%3D%22_blank%22%3E%40lezboyd%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou're%20welcome!%20It%20seems%20that%20you%20were%20selecting%20whole%20columns%20and%20you%20have%20tweaked%20the%20formula%20correctly%20now.%20Glad%20you%20found%20the%20explanation%20helpful.%3C%2FP%3E%3C%2FLINGO-BODY%3E
lezboyd
New Contributor

I am facing an issue in Excel 2010, whereby if I try to apply Conditional Formatting on a selection that also contains cells/columns with Data Validation applied, then it doesn't work as expected.

 

I am trying to apply Conditional Formatting to a worksheet such that, for all rows where the value of a particular column is "Y", then the row is colored blue. Data Validation is applied in this column for possible values Y/N/Blank only. I have tried to achieve this as under:

 

An example worksheet is attached.

 

1. Select all the columns with Data (Columns A thru N).

2. Home tab > Conditional Formatting > New Rule > option "Use a formula to determine which cells to format".

3. Under "Format values where this formula is true", enter =$K2="Y"

4. Click Format button > Fill tab > select light blue color > OK (on format window) > OK (on New Formatting Rule window).

 

This has the effect of a number of rows getting colored light blue but they are seemingly random rows, and not ones where the value in column K is "Y". I have googled this a lot, and almost all the articles confirm that I am using the right method. But I am not getting the desired results. Please help shed light on what is going wrong.

 

Thanks & Regards,

Boyd

4 Replies

Hi @lezboyd 

 

Attached please find the updated file, please let me know if it works for you

 

 

Solution

@lezboyd 

When you select a range for conditional formatting and trying to create a new rule based on a formula, always pay attention to the row# used in the formula, it must match the row# of the first row in the selected range.

So if you select the range A2:N103 and create a new rule for conditional formatting using your formula for highlighting the rows where column K has a "Y" in it, it will correctly highlight the rows as the first row in the selected range A2:N103 is row#2 and the row# of the cell you are referencing in your formula (=$K2="Y") is also row#2 and they both match.

But if you select the whole columns A:N, the first row in the selected range will be row#1 which doesn't match with the row# used in your formula which is row#2 hence the highlighted rows will be off by one row down.

 

Also, make sure that you don't have multiple conditional formatting rules for the same rule so it's always a best practice to select all the range once and not applying the conditional formatting to specific range and then using the format painter to copy the same conditional formatting to the other ranges otherwise you will end up with multiple conditional formatting rules.

 

In the attached, I have applied the conditional formatting based on your formula, see if that works as desired.

 

@Subodh_Tiwari_sktneer 

Thanks for the explanation. All the articles that I googled had examples that gave me the impression that the header row is to be ignored when entering the formula. Changing my formula to =$K1="Y" gave the expected results immediately. Thanks again.

@lezboyd 

You're welcome! It seems that you were selecting whole columns and you have tweaked the formula correctly now. Glad you found the explanation helpful.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
17 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
11 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies