using the slope function with non contiguous cells
use this UDF
=skipslope(A1:A10,B1:B10,3)
where the last number is the step size you want. In you example it will be 2
Function skipslope(ByRef x_values, ByRef y_values, slope_step)
Dim X_range() As Variant
Dim Y_range() As Variant
ReDim X_range(x_values.Count)
ReDim Y_range(y_values.Count)
Index = 0
For i = 1 To x_values.Count Step slope_step
a = x_values(i)
X_range(Index) = x_values(i)
Y_range(Index) = y_values(i)
Index = Index + 1
Next i
skipslope = WorksheetFunction.Slope(X_range, Y_range)
End Function
"fallowfz" wrote:
Is there a way to use non contiguous cells with the slope function?
Specifically, if y's and x's contain non contiguous values.
SLOPE(known_y's,known_x's)
A simple example...
x's y's
1 10
2 12
3 30
4 32
5 60
6 68
Where...
desired x's = 1, 3, 5
desired y's = 10, 30, 60
Thanks,
-Zack
|