编译错误,下一步不用

我是新来编写代码在Excel VBA中,我收到编译错误下一个没有对于…..但是我有一个和下一个,你能告诉我我做错了什么,请参阅下面的代码,谢谢!

Dim i As Integer For i = 19 To 49 If Cells(3, i) > 499999 Then Cells(4, 3) = 499999 ElseIf Cells(3, i) < 499999 Then Cells(4, 3) = Cells(3, i) End If If Cells(4, 3) < 499999 Then Cells(4, 5) = 0 If Cells(3, i) > 999999 Then Cells(4, 4) = 500000 ElseIf Cells(3, i) < 999999 Then Cells(4, 4) = Cells(3, i) - 499999 End If If Cells(4, 4) = 0 Then Cells(4, 5) = 0 ElseIf Cells(3, i) > 1999999 Then Cells(4, 5) = 1000000 ElseIf Cells(3, i) < 1999999 Then Cells(4, 5) = Cells(3, i) - 999999 End If If Cells(4, 5) = 0 Then Cells(4, 6) = 0 ElseIf Cells(3, i) > 4999999 Then Cells(4, 6) = 3000000 ElseIf Cells(3, i) < 4999999 Then Cells(4, 6) = Cells(3, i) - 1999999 End If If Cells(4, 6) = 3000000 Then Cells(4, 7) = Cells(3, i) - 4999999 ElseIf Cells(4, 6) < 3000000 Then Cells(4, 7) = 0 End If Range(7, i).Value = (Cells(5, 3) + Cells(5, 4) + Cells(5, 5) + Cells(5, 6) + Cells(5, 7)) / Cells(3, i) Next i End Sub 

在第二个If块中,replace

 If Cells(4, 3) < 499999 Then Cells(4, 5) = 0 If Cells(3, i) > 999999 Then 

 If Cells(4, 3) < 499999 Then Cells(4, 5) = 0 ElseIf Cells(3, i) > 999999 Then 

这就是VBA翻译的混淆。

  If Cells(4, 3) < 499999 Then Cells(4, 5) = 0 If Cells(3, i) > 999999 Then *****needs to elseif Cells(4, 4) = 500000 ElseIf Cells(3, i) < 999999 Then Cells(4, 4) = Cells(3, i) - 499999 End If 

你在最后一个如果blcok得到与你的代码types不匹配