SampleSize
CODE

'-------------------------------------------------------------------------------------------------------------------
' SampleSize
' http://www.utteraccess.com/wiki/SampleSize
' Code courtesy of UtterAccess Wiki
' Original submission by Diego F.Pereira-Perdomo
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev  date                          brief descripton
' 1.0  2013-10-27                    A simple formula for calculating a sample size
'                                       N: Population size.
'                                       s: Population standard deviation. If unknown = 0.5.
'                                       Z: Value appropriate for the selected confidence interval.
'                                          1.96 for a CI = 95%; 2.58 for a CI = 99%.
'                                       e: Margin of error. Usually between 1% (0.01) to 9% (0.09).
'-------------------------------------------------------------------------------------------------------------------
Function SampleSize(N As Long, _
s As Double, _
Z As Double, _
e As Double) As Long
SampleSize = (N * (s ^ 2) * (Z ^ 2)) / ((N - 1) * (e ^ 2) + (s ^ 2) * (Z ^ 2))
End Function