Excel VBA基于VbMsgBoxResult在其内部重新启动相同的子例程

J V*_*VBA 5 excel vba if-statement excel-vba msgbox

我试图让我的Sub基于MsgBoxReults重新启动。我拥有的代码不包含任何错误,但是不会根据用户的选择重新启动(希望在另一个IF中包含IF语句不是问题)

请协助。

Sub ContinueWeatherList()

Dim Weather As String
'Assigning a Message Box result as a Variable for Yes/No
Dim MoreWeather As VbMsgBoxResult

Weather = InputBox("Type in the weather for " & Range("C1").End(xlDown) + 1)

If Weather = "" Then
    MsgBox ("No data entered. Your response has not been recorded"), vbExclamation
Else
    Range("C1").End(xlDown).Offset(1, 0).Value = Range("C1").End(xlDown) + 1
    Range("A1").End(xlDown).Offset(1, 0).Value = Range("A1").End(xlDown) + 1
    Range("B1").End(xlDown).Offset(1, 0).Value = Weather
    Columns("A:C").EntireColumn.AutoFit
    MsgBox "Thank you for entering your data " & vbNewLine & "Would you like to enter another?", vbYesNo

    'Using IF statement to decide what happens for each condition
    If MoreWeather = vbYes Then
        ''Call' command won't reinitiate Sub / *NEED TO FIX*
        Call ContinueWeatherList
    Else
        MsgBox "Thank you for you input.", vbInformation
    End If

End If
Run Code Online (Sandbox Code Playgroud)

结束子