VBA IF循环有点累,请帮我合并为一个按钮.Private Sub CommandButton1_Click()If Range("_ESF2435") = "错误" ThenDim AnswerAnswer = MsgBox("合格率低于90%或者大于110%,请确定回收数量是否正确!" & Range("A2") & _vbCrLf & vbC
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/24 18:05:24
VBA IF循环有点累,请帮我合并为一个按钮.Private Sub CommandButton1_Click()If Range("_ESF2435") = "错误" ThenDim AnswerAnswer = MsgBox("合格率低于90%或者大于110%,请确定回收数量是否正确!" & Range("A2") & _vbCrLf & vbC
VBA IF循环有点累,请帮我合并为一个按钮.
Private Sub CommandButton1_Click()
If Range("_ESF2435") = "错误" Then
Dim Answer
Answer = MsgBox("合格率低于90%或者大于110%,请确定回收数量是否正确!" & Range("A2") & _
vbCrLf & vbCrLf & "确定请按“是”." & _
vbCrLf & vbCrLf & "否则,请按“否”后修改回收数量.",_
vbExclamation + vbYesNo + vbDefaultButton2,"请确认输入的回收数是否正确单")
If Answer = vbYes Then
Dim oAdd As Object
Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
bResult = oAdd.saveCase(,True,True)
If bResult = False Then
MsgBox "保存失败!"
Else
Range("E13").Select
End If
Set oAdd = Nothing
Else
Range("E13").Select
End
End If
Else
Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
bResult = oAdd.saveCase(,True,True)
If bResult = False Then
MsgBox "保存失败!"
Else
Range("E13").Select
End If
Set oAdd = Nothing
End If
End Sub
Private Sub CommandButton2_Click()
If Range("_ESF2439") > 0 Then
Dim Answer1
Answer1 = MsgBox("该工序已经存在" & Range("_ESF2439") & "张完工单,请确认是否重复输入" & _
vbCrLf & vbCrLf & "确定请按“是”." & _
vbCrLf & vbCrLf & "否则,请按“否”后修改单据.",_
vbExclamation + vbYesNo + vbDefaultButton2,"确认是否重复做单")
If Answer = vbYes Then
Dim oAdd As Object
Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
bResult = oAdd.saveCase(,True,True)
If bResult = False Then
MsgBox "保存失败!"
Else
Range("E13").Select
End If
Set oAdd = Nothing
Else
Range("E13").Select
End
End If
Else
Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
bResult = oAdd.saveCase(,True,True)
If bResult = False Then
MsgBox "保存失败!"
Else
Range("E13").Select
End If
Set oAdd = Nothing
End If
End Sub
VBA IF循环有点累,请帮我合并为一个按钮.Private Sub CommandButton1_Click()If Range("_ESF2435") = "错误" ThenDim AnswerAnswer = MsgBox("合格率低于90%或者大于110%,请确定回收数量是否正确!" & Range("A2") & _vbCrLf & vbC
这段代码十分诡异,后面的IF-ELSE-ENDIF嵌套匪夷所思,注释掉似乎也不影响运行逻辑啊.
Private Sub CommandButton1_Click()
If Range("_ESF2435") = "错误" Then
Dim Answer
Answer = MsgBox("合格率低于90%或者大于110%,请确定回收数量是否正确!" & Range("A2") & _
vbCrLf & vbCrLf & "确定请按“是”." & _
vbCrLf & vbCrLf & "否则,请按“否”后修改回收数量.",_
vbExclamation + vbYesNo + vbDefaultButton2,"请确认输入的回收数是否正确单")
If Answer = vbYes Then
Dim oAdd As Object
Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
bResult = oAdd.saveCase(,True,True)
If bResult = False Then
MsgBox "保存失败!"
Else
Range("E13").Select
End If
Set oAdd = Nothing
Else
Range("E13").Select
' End
End If
'Else
' Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
' bResult = oAdd.saveCase(,True,True)
' If bResult = False Then
' MsgBox "保存失败!"
' Else
' Range("E13").Select
' End If
' Set oAdd = Nothing
'End If
'End Sub
'
'Private Sub CommandButton2_Click()
If Range("_ESF2439") > 0 Then
Dim Answer1
Answer1 = MsgBox("该工序已经存在" & Range("_ESF2439") & "张完工单,请确认是否重复输入" & _
vbCrLf & vbCrLf & "确定请按“是”." & _
vbCrLf & vbCrLf & "否则,请按“否”后修改单据.",_
vbExclamation + vbYesNo + vbDefaultButton2,"确认是否重复做单")
If Answer = vbYes Then
Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
bResult = oAdd.saveCase(,True,True)
If bResult = False Then
MsgBox "保存失败!"
Else
Range("E13").Select
End If
Set oAdd = Nothing
Else
Range("E13").Select
' End
End If
'Else
' Set oAdd = Application.COMAddIns("ESClient10.Connect").Object
' bResult = oAdd.saveCase(,True,True)
' If bResult = False Then
' MsgBox "保存失败!"
' Else
' Range("E13").Select
' End If
' Set oAdd = Nothing
'End If
End Sub