title: VBA Excel Do while and If condition
body: <p>Following code some times it work and for more than two values it says an error mentioning a overflow.
  I just want to write a VBA code for a values in a column to separate three categories and count numbers in each category. please tell me the error of this code.</p>
  
  <pre><code>Sub income_status()
  
  Dim income As Integer
  Dim locount As Integer
  Dim mecount As Integer
  Dim hicount As Integer
  
  
  
  Do While ActiveCell.Value &lt;&gt; ""
  
      income = ActiveCell.Value
  
  
      If income &lt;= 10000 Then
      ActiveCell.Offset(0, 1).Value = "Low Income"
      locount = locount + 1
  
      ElseIf income &gt; 10000 And income &lt;= 50000 Then
  
      ActiveCell.Offset(0, 1).Value = "Medium Income"
      mecount = mecount + 1
  
      Else
  
      ActiveCell.Offset(0, 1).Value = "High Income"
      hicount = hicount + 1
  
  
      End If
      ActiveCell.Offset(1).Select
  
    Loop
      ActiveCell.Offset(1, 2).Value = locount
      ActiveCell.Offset(1, 2).Value = mecount
      ActiveCell.Offset(1, 2).Value = hicount
  
  
  End Sub
  </code></pre>