-1

我只是想学习我的代码,这里是:

Sub lala()
Dim ha As String
Dim objcell As Object
Dim ha2 As String
Dim ha3 As String
    For Each objcell In ActiveSheet
    MsgBox ("BLAH")
    ha = MsgBox("Do you want the same message box?", vbYesNo)
    If ha = vbYes Then
    Next objcell
    Else
    MsgBox("Do you want another one at all?", vbYesNo) = ha3
    If ha3 = vbYes Then
    ha2 = InputBox("What do you want it to say?")
    Else
    Exit Sub
    End If
    End If
End Sub
4

1 回答 1

0

您正在混合“if”和“for”,您的“next”在“if”语句中,而它应该在它之外。这是您的“更正”代码:

Sub lala()
    Dim ha As String
    Dim objcell As Object
    Dim ha2 As String
    Dim ha3 As String
    For Each objcell In ActiveSheet
        MsgBox ("BLAH")
        ha = MsgBox("Do you want the same message box?", vbYesNo)
        If ha = vbNo Then Exit for
    Next objcell
    MsgBox("Do you want another one at all?", vbYesNo) = ha3
    If ha3 = vbYes Then
        ha2 = InputBox("What do you want it to say?")
    Else
        Exit Sub
    End If
End Sub
于 2014-11-19T10:28:33.197 回答