title: Conditionally format cells with matching text if a checkbox is checked in Google Sheets
body: <p>How can I apply conditional formatting with a custom formula that uses text AND a checkbox as its criteria?</p>
  
  <p>I have two columns of names and I want to be able to toggle highlighting with checkboxes from a third column. So if I check the "Paul" box, all the cells with "Paul" in it will highlight.</p>
  
  <p>Desired result:</p>
  
  <p><a href="https://i.stack.imgur.com/rix7n.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rix7n.jpg" alt="enter image description here"></a></p>
  
  <p>I can achieve the proper highlights without the checkbox if I use the following formula in the Custom Formula box of Conditional Formatting: <code>=countif(B2,"Paul")</code> </p>
  
  <p>But I only want to activate this code if <code>D3=TRUE</code></p>
  
  <p>I tried <code>=IF(D3=TRUE,countif(B2:C11,"Paul"))</code> Which is a formula that works in a cell (returns the number 8)... but this only seems to highlight one cell (B2) when entered in the Custom Formula box.</p>
  
  <p>I've seen examples of checkboxes toggling formatting on cells or rows, which is where I got the <code>COUNTIF</code> code, but nothing I've seen helps with the specific text search.</p>
  
  <p>I'm happy to set up a different formatting rule for each name, unless there was a <code>HLOOKUP</code> formula that worked dynamically!</p>