这是我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
如何链接这两者?
可能是这样的:
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
根据您的评论,请试试这个:
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
的使用,并在用户没有在上面放任何东西时修改了Inputbox
的提示。