基于输入框答案运行循环(Running a loop based on input box answer)
如果输入框的答案是yes我想要运行一个宏。
所以每次运行其他宏时都需要询问这个问题我需要问问题,直到用户为他们需要的所有日期完成宏。
我把输入框放在错误的地方,但不知道放在哪里。
Call ChangeDates strMore = Application.InputBox(prompt:="Do you have any more dates to enter? Type Yes or No", Type:=2) Do Until strMore = "no" If strMore = "yes" Then Call ChangeDates End If strMore = Application.InputBox(prompt:="Do you have any more dates to enter? Type Yes or No", Type:=2) LoopI have a macro I want to run if the answer to the input box is yes.
So the question will need to be asked each time the other macro has been run I need to ask the question until the user has done the macro for all the dates they need to.
I am putting the input box in the wrong place but not sure where to put it.
Call ChangeDates strMore = Application.InputBox(prompt:="Do you have any more dates to enter? Type Yes or No", Type:=2) Do Until strMore = "no" If strMore = "yes" Then Call ChangeDates End If strMore = Application.InputBox(prompt:="Do you have any more dates to enter? Type Yes or No", Type:=2) Loop最满意答案
将此解决方案视为使用InputBox的替代方法:
Sub test() Question: If MsgBox("Do you have any more dates to enter?", vbYesNo) = vbNo Then Exit Sub Call ChangeDates GoTo Question End Sub这样,您的用户(或您)就不必输入“是”或“否”以继续/结束流程。
Consider this solution as an alternative to using an InputBox:
Sub test() Question: If MsgBox("Do you have any more dates to enter?", vbYesNo) = vbNo Then Exit Sub Call ChangeDates GoTo Question End SubThat way your users (or you) won't have to enter "Yes" or "No" in order to continue/end the process.
更多推荐
发布评论