'Unable to get the StDev property of the WorkSheetFunction class'
Ok guys, this error isn't too difficult (I don't think)...
I have problems with my newSTDEV function when a worksheet only has one line of entered data in it. I believe it's because you can't take StDev with only one value so the function returns something like #VALUE!. How can i make it so that the runtime error doesn't show up? If the result is a #VALUE! in the cell, that's perfectly fine.
On a side note, the function works when i enter it manually, but not when I use it through vba like in the line below. I checked my parameters and they look perfect.
Ok guys, this error isn't too difficult (I don't think)...
I have problems with my newSTDEV function when a worksheet only has one line of entered data in it. I believe it's because you can't take StDev with only one value so the function returns something like #VALUE!. How can i make it so that the runtime error doesn't show up? If the result is a #VALUE! in the cell, that's perfectly fine.
On a side note, the function works when i enter it manually, but not when I use it through vba like in the line below. I checked my parameters and they look perfect.
Code:
StartCol.FormulaR1C1 = "=newSTDEV(R[" & dataRow & "]C:R[" & (dataRow + 1000) & "]C, 15)"
Code:
Function newSTDEV(rangeInp As Range, iCI As Long)
'This function removes all cells with the background color index iCI from rangeInp
'and returns the new range selection's standard deviation
'Inputs:
'rangeInp: a range of cells to be checked
'iCI: color index to search rangeInp for
'Output:
'rOut: subrange of rangeInp with all cells that match iCI b.g. color removed
Application.Volatile
Dim cell As Range
Dim rOut As Range
For Each cell In rangeInp.Cells
If cell.Interior.ColorIndex <> iCI Then
If rOut Is Nothing Then Set rOut = cell
Set rOut = Union(rOut, cell)
End If
Next cell
newSTDEV = Application.WorksheetFunction.StDev(rOut)
End Function