title: VBA why infinite loop with MsgBox?
body: <p>If interested, goal of macro is to demonstrate Intermediate Value Theorem using computer (more powerful than demonstrating theorem by hand). Hence mathematical tag.</p>
  
  <p>I have VBA macro with infinite loop of first MsgBox. Why is this infinite? I have tried relocating portions of code to fix this, seems to do nothing.</p>
  
  <pre><code>Option Explicit
  Sub Function1()
  Dim Polynomial As String
  Dim Sign
  Dim counter As Integer
  Dim Degree
  Dim Coefficient
  
  While Cells(counter + 1, 1).Value &lt;&gt; "" And Cells(counter + 1, 2).Value &lt;&gt; "" '+1 because top row occupied by column A, column B titles. If cell is empty stop.
  counter = 1
  MsgBox "Enter polynomial by terms."
  counter = counter + 1
  Degree = Cells(counter + 1, 1).Value 'A2
  Coefficient = Cells(counter + 1, 2).Value 'B2
  
  If (Coefficient &lt; 0) Then
  Sign = " - " ' if coefficient negative
  Else
  If Coefficient &gt; 0 Then Sign = " + " ' if coefficient positive
  End If
  
  Polynomial = Polynomial &amp; " " &amp; Coefficient &amp; "x^" &amp; Degree 'concatenation string, list polynomial.
  counter = 1
  counter = counter + 1
  Wend
  MsgBox Polynomial
  End Sub
  </code></pre>