title: Using MONTH in If statement in Excel VBA
body: <p>I'm trying to write an Excel macro that will look at the dates in column A and print each month listed in a column F. I am trying to use a for loop and If/Else statements but I can't seem to get it to work out correctly.</p>
  
  <pre><code>y = 2
  
  Range("F2").Formula = "=MONTH(A3)"
  
  For x = 4 To RowLast - 1
      If Range("A" &amp; x).Month = Range("F" &amp; y) Then
      Else
          y = y + 1
          Range("F" &amp; y).Formula = "=MONTH(A" &amp; x &amp; ")"
      End If
  Next
  </code></pre>
  
  <p>That is what I have thus far and it should print the first month found in Cell A3 to Cell F2 (which works), then go through every other date until it hits one line above the last. The if statements should check to make sure it's a new month and if it is print the month to the next cell in column F.</p>
  
  <p>Please let me know if you have any questions. Thank you.</p>