title: How to store RGB colour in variable?
body: <p>I'm looking to store an RGB colour in a variable in an Excel VBA project, to set the background color of various cell/ranges throughout a sub.</p>
  
  <p>I want to set the colour once in a variable, so if I decide to change it throughout I only need to do it in one place.</p>
  
  <pre><code>Dim clrBlue As ColorFormat
  clrBlue = RGB(0, 0, 256)
  
  Range("a2").Interior.Color = clrBlue
  Range("b3").Interior.Color = clrBlue
  </code></pre>
  
  <p>With the above code, I'm getting runtime error:</p>
  
  <blockquote>
    <p>Object variable or With block variable not set</p>
  </blockquote>
  
  <p>I could write separate functions  (<code>SetBlue</code>, <code>SetRed</code>, <code>SetGreen</code>) to apply each colour, but that feels messy.</p>
  
  <p>Can anyone suggest what I'm doing wrong?</p>