VBA array function help needed

vbaLost

New Member
Joined
Oct 14, 2011
Messages
3
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"))}<>
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Are you sure you can't do this using worksheet functions?

Not all the formula came through but I think you want to do something like sum the values in your range that are less than the average.

I could be totally wrong of course.:)
 
Upvote 0
No I don't think any worksheet function can do this. Yes that is basically what i'm trying to do. There should be a "<" just before the first average function
 
Upvote 0
I think there's still something missing.

What in words do you want to do exactly?

What are you summing?
 
Upvote 0
I am trying to sum the square of the difference between each cell in the range, and the average value in that range. Only if the value in the cells are less than the average. Hope this makes sense:)
 
Upvote 0

Forum statistics

Threads
1,222,405
Messages
6,165,867
Members
451,989
Latest member
DannyBoy1977

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top