title: Write a formula into a cell depending on another cell value
body: <p>I was hoping to write a Macro that does a very repetitive task for me but entering VBA is harder than expected. I will learn how to program macros for excel when I have some time because it seem extremely useful, but I can't spend 5 to 12 hours this week.</p>
  
  <p>Maybe someone here can help!</p>
  
  <p>I have a few excel files that follow this pattern:</p>
  
  <pre><code>Column C - Column D
  --------------------
  text     | (empty)
  number   | (empty)
  number   | (empty)
  text     | (empty)
  number   | (empty)
  text     | (empty)
  text     | (empty)
  number   | (empty)
  text     | (empty)
  number   | (empty)
  </code></pre>
  
  <p>Where text and number alternate <strong>randomly</strong> for a few thousand cells. I need column D to hold, when column C is a number, the difference with previous number, otherwise it must stay blank:</p>
  
  <pre><code>Column C - Column D
  --------------------
  text     | (empty)
  3        | (empty)
  14       | (=C3-C2) : 11
  text     | (empty)
  16       | (=C5-C3) : 2
  text     | (empty)
  text     | (empty)
  21       | (=C8-C5) : 5
  22       | (=C9-C8) : 1
  </code></pre>
  
  <p>So the algorithm is:</p>
  
  <pre><code>var previousNumberCell
  var i = 1
  
  for all (selected) cells/rows 
   if (Row(i).column(C) holds number) {
     Row(i).column(D).value = "=C"+i+"-"C"+previousNumberCell
     previousNumberCell = i;
   }
   i++
  
  End
  </code></pre>
  
  <p>I don't care if for the first or last cell it doesn't work.</p>
  
  <p>Thank you so much for the help, or if you can point me to where I can find the answer to this.</p>
  
  <p>EDIT: this is a simplified version of the problem, there are 2 things I don't know how do well with excel macros: select a cell, and tell if cell is a number... for the record, number cells have been converted from text to number format.</p>