命令按钮代码停止工作

时间:2016-02-10 21:47:46

标签: vba excel-vba command excel

我昨天使用这个用户表单代码,一切正常。今天,没有任何工作。当我的命令按钮"完成"单击,代码应验证用户表单是否完整(Complete_Enter()),然后将信息从userform传输到我的工作表。这一切都在昨天完美运作,今天却没有。相反,当我单击完成时,VBA只运行Complete_Enter()子下的第一行。这是代码:

Id

1 个答案:

答案 0 :(得分:1)

我希望你的例行程序应该这样修改:

Private Sub Complete_Enter()
    If Serial_Number.Value = "" Then
        MsgBox "Fill in Serial Number"
    ElseIf Order_Number.Value = "" Then
        MsgBox "Fill in Order Number"
    ElseIf TextBox1.Value = "" Then
        MsgBox "Fill in Date"
    ElseIf Revision.Value = "" Then
        MsgBox "Select the correct Revision"
    ElseIf Inspector.Value = "" Then
        MsgBox "Who was the inspector? If it was you,select 'SELF'"
    ElseIf Assembler.Value = "" Then
        MsgBox "Select Your Name as the Assembler"
    ElseIf Process_Code.Value = "" Then
        MsgBox "Select the correct Process Code"
    ElseIf OptionButton1.Value = False And OptionButton21.Value = False Then
        MsgBox "What is the Status of Step 1"
    ElseIf OptionButton2.Value = False And OptionButton12.Value = False Then
        MsgBox "What is the Status of Step 2"
    ElseIf OptionButton3.Value = False And OptionButton13.Value = False Then
        MsgBox "What is the Status of Step 3"
    ElseIf OptionButton4.Value = False And OptionButton14.Value = False Then
        MsgBox "What is the Status of Step 4"
    ElseIf OptionButton5.Value = False And OptionButton15.Value = False Then
        MsgBox "What is the Status of Step 5"
    ElseIf OptionButton6.Value = False And OptionButton16.Value = False Then
        MsgBox "What is the Status of Step 6"
    End If
End Sub