我使用了"If Then If msgbox vbYesno“语句,但我不确定如何正确地摆脱它(我知道Goto不是干净的)。
谁能告诉我我的错误是什么?我没有发现任何人使用类似的东西。
Sub IF_THEN_IF()
If Sheet1.Range("A1").Value > 500 Then
If MsgBox("A1 > 500, Is this correct", vbYesNo, "Amount of Lines") = vbYes Then
Range("H11").FormulaR1C1 = "My Formula"
Else
GoTo Jump
End If
Else
Jump:
Range("H11").FormulaR1C1 = "I have Jumped"
End If
End Sub发布于 2017-10-16 21:37:31
这个答案是对你对Vityaya的回答的评论的回应。
将Jump中的代码转换为子例程,并根据需要调用它。
Sub IF_THEN_IF()
With Sheet1
If .Range("A1").Value > 500 Then
Dim res as Variant
res = MsgBox("A1 > 500, Is this correct", vbYesNo, "Amount of Lines")
If res = vbYes Then
.Range("H11").FormulaR1C1 = "My Formula"
Else
Jump
End If
Else
Jump
End If
End Sub
Sub Jump()
'code here
End Subhttps://stackoverflow.com/questions/46771236
复制相似问题