基于输入框答案运行循环(Running a loop based on input box answer)

编程入门 行业动态 更新时间:2024-10-10 05:16:54
基于输入框答案运行循环(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) Loop

I 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 Sub

That way your users (or you) won't have to enter "Yes" or "No" in order to continue/end the process.

更多推荐

本文发布于:2023-04-29 01:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334435.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:输入框   答案   Running   loop   answer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!