I have this code to interpolate for a certain value and its subsequent columns but I am having problems reporting it to another sheet. I am currently having problems reporting the derived results to another sheet
Sub interp()
Dim temp As Long
Dim var As Long
Dim var1 As Long
Dim xs As Range
Dim ys As Range
Dim lastrow As Long
Dim lastcol As Long
Dim vy As Long
temp = Sheet2.Range("a1").Value
With Worksheets(1)
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
lastcol = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column
Set xs = Range(Cells(2, 1), Cells(lastrow, 1)) 'range for xs values
For vy = 2 To lastcol 'interpolating from second column to last
Set ys = Range(Cells(2, vy), Cells(lastrow, vy))'selecting the column based on value of vy
var = WorksheetFunction.Match(temp, xs, 1)'for forecasting estimated values
var1 = var + 1 'for forecasting estimated values
y = .Range(ys.Cells(var, 1), ys.Cells(var1, 1)).Value 'for forecasting estimated values
x = .Range(xs.Cells(var, 1), xs.Cells(var1, 1)).Value 'for forecasting estimated values
Sheet2.Range(Cells(1, vy)).Value = Application.WorksheetFunction.Forecast(temp, y, x) 'interpolated value is put in a cell dependent the value of vy
Next vy
End With
End Sub