title: Excel vba calculate average of a column
body: <p>I want to calculate average of a column and put the value below.<br />
  I wrote this code in VBA but returned value is always 0.</p>
  
  <pre><code>Sub Macro4()
  '
  ' Macro4 Macro
  '
  ' Keyboard Shortcut: Ctrl+Shift+C
  Dim sum As Integer
  Dim count As Integer
  count = 0
  sum = 0
  Do While ActiveCell.Value &lt;&gt; ""
      ActiveCell.Offset(1, 0).Activate
      sum = sum + ActiveCell.Value
      count = count + 1
      Loop
  ActiveCell.Value = sum / count
  ActiveCell.Offset(0, 5).Select
  Selection.End(xlUp).Select
  Selection.End(xlUp).Select
  End Sub
  </code></pre>