Hi,
Can anyone advise me on the correct use of the Forecast function in a VBA loop. I have columns for each month of the financial year so the ranges of x, known y's and known x's are variable depending on what column is the current month's column. I have tried:
...But this gives me an Invalid number of arguments error.
I have also tried:
...But this gives me an error 2015 (x-value is not a numeric value?)
Am I doing this completely wrong? Do I need to create an array of all known x's and y's into a variable instead of just stating the ranges? Any advise would be much appreciated.
Thanks,
K
Can anyone advise me on the correct use of the Forecast function in a VBA loop. I have columns for each month of the financial year so the ranges of x, known y's and known x's are variable depending on what column is the current month's column. I have tried:
Code:
xToForecast = Worksheets("TOTALS").Columns(monthColumnInTotalsSheetLetter & ":" & monthColumnInTotalsSheetLetter).Rows("23:23").Address
forecastKnownValuesYstartCell = Worksheets("TOTALS").Columns("H:H").Rows(wb1endRowTotals - 2).Address
forecastKnownValuesYendCell = Worksheets("TOTALS").Columns(monthColumnInTotalsSheetMinusOneLetter & ":" & monthColumnInTotalsSheetMinusOneLetter).Rows(wb1endRowTotals - 2).Address
forecastKnownValuesYrange = forecastKnownValuesYstartCell & ":" & forecastKnownValuesYendCell
forecastKnownValuesXstartCell = Worksheets("TOTALS").Columns("H:H").Rows("23:23").Address
forecastKnownValuesXendCell = Worksheets("TOTALS").Columns(monthColumnInTotalsSheetMinusOneLetter & ":" & monthColumnInTotalsSheetMinusOneLetter).Rows("23:23").Address
forecastKnownValuesXrange = forecastKnownValuesXstartCell & ":" & forecastKnownValuesXendCell
params = """ & xToForecast & "","" & forecastKnownValuesYrange & "","" & forecastKnownValuesXrange & """
forecastResult = Application.Forecast(params)
I have also tried:
Code:
forecastResult = Application.Forecast(xToForecast,forecastKnownValuesYrange,forecastKnownValuesXrange)
Am I doing this completely wrong? Do I need to create an array of all known x's and y's into a variable instead of just stating the ranges? Any advise would be much appreciated.
Thanks,
K