User-defined type not defined

R

ronn2007

I am using this custom formula on a worksheet, and sometimes I get '
User-defined type not defined' error message. (However, the formula
works). How can I avoid this error?
Thanks!

Function SumActualPlusForecast(Y_Actual As Range, PeriodsRange As
Range, ValuesRange As Range, strThisYear As String) As Double

For iItem = 1 To 12
If Left(Trim(PeriodsRange.Cells.Item(iItem).Value), 4) =
strThisYear Then
intForecastTotal = intForecastTotal +
ValuesRange.Cells.Item(iItem).Value
End If
Next iItem

SumActualPlusForecast = Y_Actual + intForecastTotal

End Function
 
J

Jim Thomlinson

Try declaring your variables... Also compile your code Debug -> Compile

Function SumActualPlusForecast(Y_Actual As Range, PeriodsRange As
Range, ValuesRange As Range, strThisYear As String) As Double
dim iItem as integer
dim intForecastTotal as integer

For iItem = 1 To 12
If Left(Trim(PeriodsRange.Cells.Item(iItem).Value), 4) =
strThisYear Then
intForecastTotal = intForecastTotal +
ValuesRange.Cells.Item(iItem).Value
End If
Next iItem

SumActualPlusForecast = Y_Actual + intForecastTotal

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top