我无法获得msgbox的语法。我想要方框说:
你已表示“ “员工姓名”(工作表单元格的范围引用) 已经工作了“小时”(工作表单元格的范围引用)执行“工作”(工作表单元格的范围引用)
这些信息是否正确?
这就是我所拥有的(稍微缩短):
Public confirmation_yes_no()
Dim yesornoanswertomessagebox As String
Dim questiontomessagebox As String
questiontomessagebox = "You have indicated that" & worksheets("dept 1 input").range("g12"),"worked at" & worksheets("dept 1 input").range("g16"), "for" & worksheets("dept 1 input").range("g16"), vbinformation, "Are you sure that this data is correct?"
yesornoanswertomessagebox = MsgBox(questiontomessagebox, vbYesNo, "FlightPlan for Profits PRO")
If yesornoanswertomessagebox = vbNo Then
MsgBox "Return to Data Input to correct error(s)", 0, "FlightPlan for Profits PRO"
Else
MsgBox "Great! Press Enter", 0, "FlightPlan for Profits PRO"
End If
End Sub
我当然假设这是可能的。
答案 0 :(得分:2)
嗨,你错过了“&”迹象。所以我为你纠正它。
numbers, names, deleted and added
答案 1 :(得分:2)
您的代码很多事情,
Public confirmation_yes_no()
的开头行,它是什么,它是一个子,函数还是什么,它现在写的方式是全局变量声明。&
,但请务必手动在其周围放置空格,否则无法识别。 &var1
<> & var1
Worksheets("dept 1 input")
,请考虑使用如下所示的With
语句,这样您就不必在With
语句中反复输入该位。请注意,要使用with语句,请在代码前面写.
。.Range(...
指向由With
语句设置的工作表。< br /> Range(...
指向Excel认为处于活动状态的工作表。_
,以表明它在下一行继续,而不是非常非常长的行。 If
声明中使用消息框。更正后的代码
Public Sub confirmation_yes_no()
Dim questiontomessagebox As String
With ThisWorkbook.Worksheets("dept 1 input")
questiontomessagebox = "You have indicated that " & .Range("G12") & " worked at " _
& .Range("G16") & " for " & .Range("G16") & "." _
& vbCr & vbCr _
& "Are you sure that this data is correct?"
End With
If MsgBox(questiontomessagebox, vbYesNo, "FlightPlan for Profits PRO") = vbNo Then
MsgBox "Return to Data Input to correct error(s)", 0, "FlightPlan for Profits PRO"
Else
MsgBox "Great! Press Enter", 0, "FlightPlan for Profits PRO"
End If
End Sub