I am trying to write the following function using VBA. My data is for example in cells C6 to F6.
{=SUM(IF(C6:F6AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}<?XML:NAMESPACE PREFIX = AVERAGE(C6 /><AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}< p>
<AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}< p>
I have come up with (but don't know how to make it an array formula):
Function ifSD(TheRange As Variant)
tst = Evaluate(TheRange < Application.WorksheetFunction.Average(TheRange))
s2 = (TheRange - Application.WorksheetFunction.Average(TheRange)) ^ 2
s3 = "no"
If tst = True Then
ifSD = application.worksheetfunction.sum(s2)
Else
ifSD = s3
End If
End Function
</AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}<>
</AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}<>
{=SUM(IF(C6:F6AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}<?XML:NAMESPACE PREFIX = AVERAGE(C6 /><AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}< p>
<AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}< p>
I have come up with (but don't know how to make it an array formula):
Function ifSD(TheRange As Variant)
tst = Evaluate(TheRange < Application.WorksheetFunction.Average(TheRange))
s2 = (TheRange - Application.WorksheetFunction.Average(TheRange)) ^ 2
s3 = "no"
If tst = True Then
ifSD = application.worksheetfunction.sum(s2)
Else
ifSD = s3
End If
End Function
</AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}<>
</AVERAGE(C6:F6),(C6:F6-AVERAGE(C6:F6))^2,"no"))}<>
Last edited: