Forum Discussion
conditional formatting based on content of another cell
- Apr 13, 2021
Select the cells that you want to format conditionally. If more than one, the top left cell should be the active cell in the selection. Note the address of this cell.
On the Home tab of the ribbon. select Conditional Formatting > New Rule...
Select 'Use a formula to determine which cells to format'.
Enter a formula that evaluates to TRUE (or a non-zero number) if the rule should be applied, and to FALSE (or 0) otherwise.
In your example, let's say A2 is the active cell in the selection.
Use the following formula:
=B2<>""
Click Format...
Activate the Fill tab.
Specify the desired color (green in your example).
Click OK, then click OK again.
HansVogelaar I was wondering if you could please assist me? I have a register list that I am creating and I would like a range of cells to be populated and highlighted if a certain cell is populated with a particular code. I have tried reading through parts of this thread to see if anything helps but most of it I had already tried to no avail. I think complicating the matter is that all of the columns have a data validation drop down list. For example: If in A1 "FO" is selected from the list, I would like B1:E1 to all be highlighted a particular colour, as well as automatically be populated with "FO" as well, without having to manually do it from their own lists. If possible though, I would still like for the data validation in B1:E1 to then override what is in A1. So if something changes and D1 for example now has to be a different code, I can still manually select it from the drop down list. Thank you.
That sounds doable. Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?
- BremnerRAug 30, 2024Copper Contributor
HansVogelaar I can't find where/how to attach an example? (Can't send through OneDrive.)
- HansVogelaarAug 30, 2024MVP
See the attached version.
I did three things:
- I created a Worksheet_Change event procedure in the worksheet module to update columns C to F when a cell in A6:A10 is changed.
- As a result, I had to save the workbook as a macro-enabled workbook (*.xlsm).
- I expanded the 'Applies to' range of the conditional formatting rules to column F.
- HansVogelaarAug 30, 2024MVP
Click on my user picture, and send me a private message - you should be able to attach a file there.