I found this VBA code and am trying to format it to my specific spread sheet and I am having difficulties doing so. I am trying to find the date where my funds will run out and this code should work but it is not. I am not an expert in VBA so I am asking for some help in troubleshooting the Code. One Line on my spreadsheet is below along with the VBA code.
Thanks you to anyone that can help.
StartDate AvailableFunding AwardFee JuneForecast JulyForecast AugustForecast SeptemberForecast
6/1/2015 $430,000 $65,000 $137,000 $99,000 $121,000 $115,000
Public Function BurnoutDate(StartDate As Range, AvailableFunding As Range, AwardFee As Range, JuneForecast As Range, JulyForecast As Range, AugustForecast As Range, September As Range)
'Custom calculate value to zero
Dim curDate As Date
Dim curVal As Long, depVal As Integer
BurnoutDate = "#N/A"
If Not IsDate(StartDate) Then GoTo ExitOther
If Not IsNumeric(AvailableFunding) Then GoTo ExitOther
If Not IsNumeric(AwardFee) Then GoTo ExitOther
If Not IsNumeric(JuneForecast) Then GoTo ExitOther
If Not IsNumeric(JulyForecast) Then GoTo ExitOther
If Not IsNumeric(AugustForecast) Then GoTo ExitOther
If Not IsNumeric(SeptemberForecast) Then GoTo ExitOther
curDate = StartDate
curVal = AvailableFunding
Do While curVal > 0
Select Case curDate
Case Is = 1
depVal = JuneForecast
curVal = curVal - depVal
Case Else
depVal = JulyForecast
curVal = curVal - depVal
End Select
adjustment = JuneForecast + JulyForecast
If doDebug Then Debug.Print Format(curDate, "ddd"), depVal, curVal
curDate = curDate + 1
DoEvents
Loop
ExitNormal:
BurnoutDate = curDate
Exit Function
ExitOther:
udfBurnoutDate = "#N/A"
End Function
Thanks you to anyone that can help.
StartDate AvailableFunding AwardFee JuneForecast JulyForecast AugustForecast SeptemberForecast
6/1/2015 $430,000 $65,000 $137,000 $99,000 $121,000 $115,000
Public Function BurnoutDate(StartDate As Range, AvailableFunding As Range, AwardFee As Range, JuneForecast As Range, JulyForecast As Range, AugustForecast As Range, September As Range)
'Custom calculate value to zero
Dim curDate As Date
Dim curVal As Long, depVal As Integer
BurnoutDate = "#N/A"
If Not IsDate(StartDate) Then GoTo ExitOther
If Not IsNumeric(AvailableFunding) Then GoTo ExitOther
If Not IsNumeric(AwardFee) Then GoTo ExitOther
If Not IsNumeric(JuneForecast) Then GoTo ExitOther
If Not IsNumeric(JulyForecast) Then GoTo ExitOther
If Not IsNumeric(AugustForecast) Then GoTo ExitOther
If Not IsNumeric(SeptemberForecast) Then GoTo ExitOther
curDate = StartDate
curVal = AvailableFunding
Do While curVal > 0
Select Case curDate
Case Is = 1
depVal = JuneForecast
curVal = curVal - depVal
Case Else
depVal = JulyForecast
curVal = curVal - depVal
End Select
adjustment = JuneForecast + JulyForecast
If doDebug Then Debug.Print Format(curDate, "ddd"), depVal, curVal
curDate = curDate + 1
DoEvents
Loop
ExitNormal:
BurnoutDate = curDate
Exit Function
ExitOther:
udfBurnoutDate = "#N/A"
End Function