来自嵌套的否则错误,没有 If 语句 VBA Excel,我错过了什么?



我遇到了以下问题。我有一个电子表格,它获取 SEC 数据并将其解析为财务指标供我评估。然而,我是一个非常糟糕的程序员,我真的不确定我在这里做错了什么。我在以下块中不断收到没有 If 错误的 Else,在ElseIf lngIteratorPhi = 271.如果有帮助,我已经包括了前面和后面的块。抱歉,如果我错过了一些明显的东西,我的大脑在 VBA 应用程序上融化了。

ElseIf lngIteratorPhi = 270 Then   'dcf calculator EPS
dblAverageFCFGrowthRateOverPast10Years = dblMinGrowthRate
If IsError(Sheets("Workout").Cells(1 + lngIteratorAlpha, 105).Value) = False _
And IsEmpty(Sheets("Workout").Cells(1 + lngIteratorAlpha, 105).Value) = False _
And Sheets("Workout").Cells(1 + lngIteratorAlpha, 105).Value <> 0 Then
dblAverageFCFGrowthRateOverPast10Years = Sheets("Workout").Cells(1 + lngIteratorAlpha, 105).Value / 100
Else
dblAverageFCFGrowthRateOverPast10Years = dblMinGrowthRate
End If
If dblAverageFCFGrowthRateOverPast10Years >= 0.2 Then
dblAverageFCFGrowthRateOverPast10Years = dblMaxGrowthRate
ElseIf dblAverageEarningsGrowthRateOverPast10Years <= 0.05 Then
dblAverageFCFGrowthRateOverPast10Years = dblMinGrowthRate
Else
dblAverageFCFGrowthRateOverPast10Years = dblMinGrowthRate
End If
dblAverageFCFGrowthRateOverPast10Years = dblGrowthRateInGrowthStage
If IsError(Sheets("Workout").Cells(1 + lngIteratorAlpha, 260).Value) = False _
And IsEmpty(Sheets("Workout").Cells(1 + lngIteratorAlpha, 260).Value) = False _
And Sheets("Workout").Cells(1 + lngIteratorAlpha, 260).Value <> 0 Then
dblFCF = Sheets("Workout").Cells(1 + lngIteratorAlpha, 260).Value
End If
strGrowthPeriodCalcEqTemp = ""
strTerminalPeriodCalcEqTemp = ""
For n = 1 To intYearsOfGrowthStage
strGrowthPeriodCalcEqTemp = "((1 + " & dblGrowthRateInGrowthStage & ")^" & n & "/ (1 +" & dblDiscountRate & ")^" & n & ") +"
strGrowthPeriodCalcEq = strGrowthPeriodCalcEq & strGrowthPeriodCalcEqTemp
If n = intYearsOfGrowthStage Then
strGrowthPeriodCalcEq = Left(strGrowthPeriodCalcEq, Len(strGrowthPeriodCalcEq) - 2)
strGrowthPeriodCalcEq = strGrowthPeriodCalcEq & ")"
End If
Next n
dblGrowthPeriodCalc = Eval(strGrowthPeriodCalcEq)
For n = 1 To intYearsOfTerminalGrowth
strTerminalPeriodCalcEqTemp = "((1 + " & dblTerminalGrowthRate & ")^" & n & "/ (1 +" & dblDiscountRate & ")^" & n & ") +"
strTerminalPeriodCalcEq = strTerminalPeriodCalcEq & strTerminalPeriodCalcEqTemp
If n = intYearsOfTerminalGrowth Then
strTerminalPeriodCalcEq = Left(strTerminalPeriodCalcEq, Len(strTerminalPeriodCalcEq) - 2)
strTerminalPeriodCalcEq = strTerminalPeriodCalcEq & ")"
End If
Next n
dblTerminalPeriodCalc = Eval(strTerminalPeriodCalcEq)
dblDCFFCF = dblFCF * (dblGrowthPeriodCalc + dblTerminalPeriodCalc)
With Sheets("Workout").Cells(1 + lngIteratorAlpha, 0 + lngIteratorPhi)
.NumberFormat = "$???,??0.00;[red]-$???,??0.00;$???,??0.00" ' currency for under 100,000 dollars
End With
Else
With Sheets("Workout").Cells(1 + lngIteratorAlpha, 0 + lngIteratorPhi)
.Value = "NULL"
End With
ElseIf lngIteratorPhi = 271 Then   'dcf calculator EPS
dblAverageEarningsGrowthRateOverPast10Years = dblMinGrowthRate
If IsError(Sheets("Workout").Cells(1 + lngIteratorAlpha, 98).Value) = False _
And IsEmpty(Sheets("Workout").Cells(1 + lngIteratorAlpha, 98).Value) = False _
And Sheets("Workout").Cells(1 + lngIteratorAlpha, 98).Value <> 0 Then
dblAverageEarningsGrowthRateOverPast10Years = Sheets("Workout").Cells(1 + lngIteratorAlpha, 98).Value / 100
End If
If dblAverageEarningsGrowthRateOverPast10Years >= 0.2 Then
dblAverageEarningsGrowthRateOverPast10Years = dblMaxGrowthRate
ElseIf dblAverageEarningsGrowthRateOverPast10Years <= 0.05 Then
dblAverageEarningsGrowthRateOverPast10Years = dblMinGrowthRate
End If
dblAverageEarningsGrowthRateOverPast10Years = dblGrowthRateInGrowthStage
If IsError(Sheets("Workout").Cells(1 + lngIteratorAlpha, 11).Value) = False _
And IsEmpty(Sheets("Workout").Cells(1 + lngIteratorAlpha, 11).Value) = False _
And Sheets("Workout").Cells(1 + lngIteratorAlpha, 11).Value <> 0 Then
dblEPS = Sheets("Workout").Cells(1 + lngIteratorAlpha, 11).Value
End If
For n = 1 To intYearsOfGrowthStage
strGrowthPeriodCalcEqTemp = ""
strGrowthPeriodCalcEqTemp = "((1 + " & dblGrowthRateInGrowthStage & ")^" & n & "/ (1 +" & dblDiscountRate & ")^" & n & ") +"
strGrowthPeriodCalcEq = strGrowthPeriodCalcEq & strGrowthPeriodCalcEqTemp
If n = intYearsOfGrowthStage Then
strGrowthPeriodCalcEq = Left(strGrowthPeriodCalcEq, Len(strGrowthPeriodCalcEq) - 2)
strGrowthPeriodCalcEq = strGrowthPeriodCalcEq & ")"
End If
Next n
dblGrowthPeriodCalc = Eval(strGrowthPeriodCalcEq)
For n = 1 To intYearsOfTerminalGrowth
strTerminalPeriodCalcEqTemp = ""
strTerminalPeriodCalcEqTemp = "((1 + " & dblTerminalGrowthRate & ")^" & n & "/ (1 +" & dblDiscountRate & ")^" & n & ") +"
strTerminalPeriodCalcEq = strTerminalPeriodCalcEq & strTerminalPeriodCalcEqTemp
If n = intYearsOfTerminalGrowth Then
strTerminalPeriodCalcEq = Left(strTerminalPeriodCalcEq, Len(strTerminalPeriodCalcEq) - 2)
strTerminalPeriodCalcEq = strTerminalPeriodCalcEq & ")"
End If
Next n
dblTerminalPeriodCalc = Eval(strTerminalPeriodCalcEq)
dblDCFEPS = dblEPS * (dblGrowthPeriodCalc + dblTerminalPeriodCalc)
With Sheets("Workout").Cells(1 + lngIteratorAlpha, 0 + lngIteratorPhi)
.NumberFormat = "$???,??0.00;[red]-$???,??0.00;$???,??0.00" ' currency for under 100,000 dollars
End With
Else
With Sheets("Workout").Cells(1 + lngIteratorAlpha, 0 + lngIteratorPhi)
.Value = "NULL"
End With
ElseIf lngIteratorPhi = 273 Then
If IsError(Sheets("Workout").Cells(1 + lngIteratorAlpha, 270).Value) = False _
And IsEmpty(Sheets("Workout").Cells(1 + lngIteratorAlpha, 270).Value) = False _
And Sheets("Workout").Cells(1 + lngIteratorAlpha, 270).Value <> 0 Then
With Sheets("Workout").Cells(1 + lngIteratorAlpha, 0 + lngIteratorPhi)
.Value = Sheets("Workout").Cells(1 + lngIteratorAlpha, 270).Value * 0.85
.NumberFormat = "$???,??0.00;[red]-$???,??0.00;$???,??0.00" ' currency for under 100,000 dollars
End With
Else
With Sheets("Workout").Cells(1 + lngIteratorAlpha, 0 + lngIteratorPhi)
.Value = "NULL"
End With
End If

哦,我现在看到我最后有一个额外的 Else。标记为已解决!

最新更新