I want to change the formatting of a cell if the cell is not valid. In this case, "valid" means that the cell has failed the data validation rules.
I'm asking this question because I couldn't find the answer on SO. I eventually solved it. I'll post my answer and see if people want to comment or provide a better answer!
Excel's conditional formatting tool applies formatting depending on cells' contents. Validation rules can change cells font, style, size or border. They can also change the text's color.
Select the range D2:D20. On the Home ribbon click the Conditional Formatting icon drop down and select New Rule. When creating a formula for a range it is important to build the formula to work with the first cell in the range, in this case cell D2. The formula you create must return TRUE to apply the format.
Here's a basic outline that I want to turn into a better formatted answer later this week when I have more time.
this:
Public Function IS_VALID(row, column) As Boolean
IS_VALID = Not Cells(row, column).Validation.value
End Function
Finally, you can set your conditional formatting effects to whatever you want, like coloring the cell red. This answer worked for me, and I wanted to not forget to add it to SO, but don't have the time to make it all pretty right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With