I have rows where the alternating cells are daters and values. I want to use the Slope formula but it wants the arguments as variable type double. It recognizes dates in Excel but not VBA. Can I make this work?
Code:
Sub t()
For x = 2 To Application.WorksheetFunction.CountA(Columns(1))
c = Application.WorksheetFunction.CountA(Rows(x))
ReDim d((c - 1) / 2) As Date
ReDim v((c - 1) / 2) As Double
For y = 2 To c Step 2
d(y / 2) = Cells(x, y)
v((y / 2) + 1) = Cells(x, y + 1)
Next y
s = Application.WorksheetFunction.Slope(d, v)
Cells(x, y + 1) = s
Next x
End Sub