vba - 为什么我的Excel VBA代码中出现 “End of Statement”编译错误?

标签 vba excel compiler-errors

下面是我在VBA中的代码:

Sub Hamza_Starting_to_Learn()

Dim Hamza_Variable As Long

Hamza_Variable = 7

If Hamza_Variable = 7 Then

MsgBox Hamza_Variable & " Is da bomb"

Elself Hamza_Variable > 7 Then

MsgBox Hamza_Variable & " Is da bigger bomb"

Else

MsgBox Hamza_Variable & "We got ourselves a problem here bro"

End If

它在下面的行中不断给出编译错误“语句结束”:
Elself Hamza_Variable > 7 Then

它突出显示Then并给出此错误。

最佳答案

尝试这个:

Sub Hamza_Starting_to_Learn()

    Dim Hamza_Variable As Long

        Hamza_Variable = 7

    If (Hamza_Variable = 7) Then

        MsgBox Hamza_Variable & " Is da bomb"

    ElseIf Hamza_Variable > 7 Then

        MsgBox Hamza_Variable & " Is da bigger bomb"

    Else

        MsgBox Hamza_Variable & "We got ourselves a problem here bro"

    End If

End Sub

您没有使用End Sub结束子例程

关于vba - 为什么我的Excel VBA代码中出现 “End of Statement”编译错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44381533/

相关文章:

.net - Visual Studio : Compiler Warnings and errors appear twice in different languages

Excel 使用 INDEX 从命名范围中获取行会导致公式错误

vba - Excel VBA : To store 'a word in a string' into a variable if that word is there in an array of strings

r - writexl 的正确日期格式是什么

Python和从excel文件中导入 float

java - 下面的代码在某些IDE中而不是在某些IDE中进行编译 “Java is Unsound”

c++ - 赛格温 : no header file found

excel - 如何检查特定范围内是否有任何彩色单元格?

vba - 在excel vba中为特定范围设置自定义数字格式时键入不匹配错误

sql - 使用 SQL 将列的格式更改为百分比