2
votes

Using Excel 2010, I want to be able to see the (population) standard deviation of the cells I select, in the status bar. I know you can alter the status bar, but I have no VB knowledge whatsoever, so I have no idea how to implement this. Is there anybody here that already has done this, or can tell me how to do this?

I've found the following code online, and it works, but it gives me the SD of the sample, not of the population (so I want to divide by N, not N-1, where is N is the number of selected cells).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sDev
sDev = Selection.Address(0, 0)
On Error GoTo errhandler
Application.StatusBar = "Standard deviation is " & _
Format(Application.StDev(Range(sDev)), "#.####")
Exit Sub errhandler:
Application.StatusBar = False
End Sub

1

1 Answers

0
votes

I haven't tested this in VBA, but you could try:

Format(Application.StDevP(Range(sDev)), "#.####")

In Excel(2007 and earlier) the standard deviation formulas are StDev() for a sample or StDevP() for the population