title: Run a function in real time on Excel Macro
body: <p>I need some idea to make this function update in real time. This function count the color of the cells for a work I need.</p>
  
  <pre><code>Function COUNTCOLOR(celdaOrigen As Range, rango As Range)
  
  Application.Volatile
  
  Dim celda As Range
  
  For Each celda In rango
  
      If celda.Interior.Color = celdaOrigen.Interior.Color Then
          COUNTCOLOR = COUNTCOLOR + 1
      End If
  
  Next celda
  
  End Function
  </code></pre>
  
  <p>I already try to run this function</p>
  
  <pre><code>Application.CalculateFullRebuild
  </code></pre>
  
  <p>But It didn't work in real time, I had to assign that function to a button and when I want to update the cells which count the colors I press the button, but that's not what I want. I want the cells count the colors in real time, I want they show me the number immediately I change a color. The cell that count the color has the following formula:</p>
  
  <pre><code>=COUNTCOLOR(A1;A1:A9998)
  </code></pre>
  
  <p>Where "A1" is a cell of the color I want the cell counts (like a sample), and the "A1:A9998" is the range where I want the formula find the color a the previous assigned sample. The cell will show a number of the cells in the range with the color of the sample.</p>
  
  <p>I hop this information I provided can help you to give me a good answer :)</p>
  
  <p>Thank you so much!</p>