这是我的Inputbox
代码:
Private Sub Q1No_Click()
Dim myResponse As String
myResponse = InputBox("Reason for not atten Morning MOM", "Mention Reason", 0, 0)
Range("G4") = myResponse
End Sub
这是我的Msgbox
代码:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range
Set rng = Range("C22")
If Application.Intersect(Target, rng) Is Nothing Then
MsgBox "You must select the answer from the list"
End If
如何链接这两个?
答案 0 :(得分:0)
可能类似于:
Private Sub Q1No_Click()
Dim myResponse As String
Do
myResponse = InputBox("Reason for not atten Morning MOM", "Mention Reason", 0, 0)
If myResponse = "" Then MsgBox "mention the reason"
Loop While myResponse = ""
Range("G4") = myResponse
End Sub
答案 1 :(得分:0)
根据您的评论,尝试一下:
.so
这将强制在Sub marine()
Dim myprompt As String, myresponse As String
myprompt = "Reason for not attending morning MOM:"
With Sheet1 '/* this is your sheet */
Do
myresponse = InputBox(myprompt, "Mention Reason")
myprompt = "No reason provided." & vbNewLine & _
"Please provide a reason and try again."
Loop Until Len(myresponse) > 0
.Range("G4").Value2 = myresponse
End With
End Sub
上放置内容。
我放弃使用Inputbox
,而是修改了Msgbox
的提示,如果用户没有在其上放任何东西。