title: Syntax Error trying to write a formula into a cell with VBA
body: <p>Not actually familiar with visual basic but used some references to make this.</p>
  <p>I would like to ask since I spent an hour figuring out how to solve this, may be I need some suggestions. I am encountering this error in Visual Basic to make macros for excel. At first it was working but after I added some lines the syntax turns red and when run the macro it just have a</p>
  <blockquote>
  <p>Compile Error: Syntax Error</p>
  </blockquote>
  <pre><code>Range(&quot;D2&quot;).Select
  ActiveCell.FormulaR1C1 = _
      &quot;=IF(ISNUMBER(SEARCH(&quot;&quot;California&quot;&quot;,RC[-2],1)),&quot;&quot;California&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Florida&quot;&quot;,RC[-2],1)),&quot;&quot;Florida&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Texas&quot;&quot;,RC[-2],1)),&quot;&quot;Texas&quot;&quot;, IF(ISNUMBER(SEARCH(&quot;&quot;New 
      Mexico&quot;&quot;,RC[-2],1)),&quot;&quot;New Mexico&quot;&quot;, IF(ISNUMBER(SEARCH(&quot;&quot;Alaska&quot;&quot;,RC[-2],1)),&quot;&quot;Alaska&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;New Jersey&quot;&quot;,RC[-2],1)),&quot;&quot;New Jersey&quot;&quot;,
      &quot;&quot;&quot;&quot;))))))&amp;IF(ISNUMBER(SEARCH(&quot;&quot;Marikina&quot;&quot;,RC[-2],1)),&quot;&quot;Marikina&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Maryland&quot;&quot;,RC[-2],1)),&quot;&quot;Maryland&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Nebraska&quot;&quot;,RC[-2],1)),&quot;&quot;Nebraska&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Pennsylvania&quot;&quot;,RC[-2],1)),&quot;&quot;Pennsylvania&quot;&quot;,   
      IF(ISNUMBER(SEARCH(&quot;&quot;Illinois&quot;&quot;,RC[-2],1)),&quot;&quot;Illinois&quot;&quot;,
      IF(ISNUMBER(SEARCH(&quot;&quot;Colorado&quot;&quot;,RC[-2],1)),&quot;&quot;Colorado&quot;&quot;,&quot;&quot;&quot;&quot;))))))&amp;
      IF(ISNUMBER(SEARCH(&quot;&quot;Louisiana&quot;&quot;,RC[-2],1)),&quot;&quot;Louisiana&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Idaho&quot;&quot;,RC[-2],1)),&quot;&quot;Idaho&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Hawaii&quot;&quot;,RC[-2],1)),&quot;&quot;Hawaii&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;Vermont&quot;&quot;,RC[-2],1)),&quot;&quot;Vermont&quot;&quot;, 
      IF(ISNUMBER(SEARCH(&quot;&quot;West Virginia&quot;&quot;,RC[-2],1)),&quot;&quot;West Virginia&quot;&quot;,           
      IF(ISNUMBER(SEARCH(&quot;&quot;Connecticut&quot;&quot;,RC[-2],1)), 
      &quot;&quot;Connecticut&quot;&quot;,&quot;&quot;&quot;&quot;)))))&quot;
  Range(&quot;D2&quot;).Select
   Selection.AutoFill Destination:=Range(&quot;D2:D38&quot;), Type:=xlFillDefault
   Range(&quot;D2:D38&quot;).Select
   ActiveWindow.SmallScroll Down:=-39
  End Sub
  </code></pre>