我想执行以下任务:Excel的VBA:如何捕获MSGBOX响应
写的留言“你醒了?”和显示问号
捕获在整数响应变量INTR,放INTR值在单元格A2
如果响应为是,则在单元格A1“乌拉”写
如果响应为否,则写有文字“ZZZZZZZZ”
一个消息框,如果响应取消,然后退出子
Sub EX3_1_6MsgBoxFunction() Dim intR As Integer Dim TxtRng As Range Dim stra As String Dim stra2 As String 'Have the message box display the buttons Yes, No and Cancel intR = MsgBox("Are you awake ? ", vbQuestion + vbYesNoCancel) intR = Range("a2") If intR = vbYes Then Range("a1") = "Hurray" 'that means yes ElseIf intR = vbNo Then stra2 = MsgBox("ZZZZZZZZZZ") Else Range("a2") = intR End If End Sub
我有我的end end在最后,但我没有复制它:) –
你的第一个错误是'intR = Range(“a2”)'而不是Range(“a2”)Value = intR' – YowE3K