Performing Statistics Functions in VBA
<p>I'm trying to perform statistical functions in VBA but I've run into a wall. I have everything set up as you can see. The average function works fine but the others are failing. Any help would be amazing!</p>

<pre><code> Private Sub CommandButton1_Click()

 Dim Counter As Integer
 Dim Count
 Dim Total As Integer
 Dim Average As Integer
 Dim Std_Dev As Integer
 Dim Max As Integer
 Dim Min As Integer
 Dim Median As Integer

 With ListBox1
     For Counter = 0 To .ListCount - 1

         If .Selected(Counter) Then
             Count = Count + 1
             Total = Total + .List(Counter)
         End If
     Next Counter
 End With

 Average = (Total / Count)
 'Std_Dev = Application.WorksheetFunction.StDev_S()
 Max = Application.WorksheetFunction.Max(ListBox1.ListCount)
 'Min = Application.WorksheetFunction.Min()
 'Median = Application.WorksheetFunction.Median()

 Unload Me
 MsgBox "Test. " &amp; Std_Dev
 End Sub

 Private Sub CommandButton2_Click()
 Unload Me
 End Sub

 Private Sub UserForm_Click()

 End Sub

 Private Sub UserForm_Initialize()

 For Each cell In Range("Scores")
     ListBox1.AddItem cell.Value
 Next

 End Sub
</code></pre>