Option Base 1
Option Explicit
Function xbarpm2se(rngX)
    Dim barX As Double, s As Double, se As Double, n As Long
    Dim matrixAns(6, 2) As Variant
    
    n = rngX.Cells.Count
    barX = WorksheetFunction.Average(rngX)
    s = WorksheetFunction.StDev_S(rngX)
    se = 
    
    matrixAns(1, 1) = "n="
    matrixAns(1, 2) = n
    
    matrixAns(2, 1) = "標本平均"
    matrixAns(2, 2) = barX
    
    matrixAns(3, 1) = "標本標準偏差"
    matrixAns(3, 2) = s
        
    matrixAns(4, 1) = "標本平均の標準誤差"
    matrixAns(4, 2) = se
    
    matrixAns(5, 1) = "平均-2標準誤差"
    matrixAns(5, 2) = barX - 2 * se
    
    matrixAns(6, 1) = "平均+2標準誤差"
    matrixAns(6, 2) = 
    xbarpm2se = matrixAns
End Function
