![]() |
Answering InpBox prompt
Is there any VBA code for answering an InputBox Prompt of another macro.
e.g. running macro "Update_at_dayend" Sub Update_at_dayend() Application.Run "Manual_Input" ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input() Dim ans as variant ans = InputBox(prompt:=" Enter Tax Rate for the area." ' the rest of the program End Sub Thanks |
Not that I know of. But if you can see the code for Manual_Input, maybe you can
change it slightly: Option Explicit Sub Update_at_dayend() Call Manual_Input(ans:="8.25%") ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input(Optional ans As Variant = "") If ans = "" Then ans = InputBox(prompt:=" Enter Tax Rate for the area.") End If MsgBox ans ' the rest of the program End Sub And since the code is in the same workbook, I replaced Application.run with a simple Call. lashio wrote: Is there any VBA code for answering an InputBox Prompt of another macro. e.g. running macro "Update_at_dayend" Sub Update_at_dayend() Application.Run "Manual_Input" ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input() Dim ans as variant ans = InputBox(prompt:=" Enter Tax Rate for the area." ' the rest of the program End Sub Thanks -- Dave Peterson |
Hi, Dave
What do you call this? Sub Manual_Input(Optional ans As Variant = "") Is it a function? It was not listed as macro; so, it can not be run independently. Thanks "Dave Peterson" wrote in message ... Not that I know of. But if you can see the code for Manual_Input, maybe you can change it slightly: Option Explicit Sub Update_at_dayend() Call Manual_Input(ans:="8.25%") ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input(Optional ans As Variant = "") If ans = "" Then ans = InputBox(prompt:=" Enter Tax Rate for the area.") End If MsgBox ans ' the rest of the program End Sub And since the code is in the same workbook, I replaced Application.run with a simple Call. lashio wrote: Is there any VBA code for answering an InputBox Prompt of another macro. e.g. running macro "Update_at_dayend" Sub Update_at_dayend() Application.Run "Manual_Input" ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input() Dim ans as variant ans = InputBox(prompt:=" Enter Tax Rate for the area." ' the rest of the program End Sub Thanks -- Dave Peterson |
It's still a subroutine.
But since it has parameters (even optional parms), you don't see it in the list. You can still type it in the Tools|macro|macros dialog if you want. ===== I find telling people to run macros that way less than optimal. If you want to give the user a nicer interface to run your macros... I use a variation of John Walkenbach's menumaker: http://j-walk.com/ss/excel/tips/tip53.htm to add items to the worksheet menubar. If I want to add a toolbar of my own, here's how I do it: http://groups.google.co.uk/groups?th...5B41%40msn.com lashio wrote: Hi, Dave What do you call this? Sub Manual_Input(Optional ans As Variant = "") Is it a function? It was not listed as macro; so, it can not be run independently. Thanks "Dave Peterson" wrote in message ... Not that I know of. But if you can see the code for Manual_Input, maybe you can change it slightly: Option Explicit Sub Update_at_dayend() Call Manual_Input(ans:="8.25%") ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input(Optional ans As Variant = "") If ans = "" Then ans = InputBox(prompt:=" Enter Tax Rate for the area.") End If MsgBox ans ' the rest of the program End Sub And since the code is in the same workbook, I replaced Application.run with a simple Call. lashio wrote: Is there any VBA code for answering an InputBox Prompt of another macro. e.g. running macro "Update_at_dayend" Sub Update_at_dayend() Application.Run "Manual_Input" ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input() Dim ans as variant ans = InputBox(prompt:=" Enter Tax Rate for the area." ' the rest of the program End Sub Thanks -- Dave Peterson -- Dave Peterson |
Thank you very much.
I will look into your suggestion "Dave Peterson" wrote in message ... It's still a subroutine. But since it has parameters (even optional parms), you don't see it in the list. You can still type it in the Tools|macro|macros dialog if you want. ===== I find telling people to run macros that way less than optimal. If you want to give the user a nicer interface to run your macros... I use a variation of John Walkenbach's menumaker: http://j-walk.com/ss/excel/tips/tip53.htm to add items to the worksheet menubar. If I want to add a toolbar of my own, here's how I do it: http://groups.google.co.uk/groups?th...5B41%40msn.com lashio wrote: Hi, Dave What do you call this? Sub Manual_Input(Optional ans As Variant = "") Is it a function? It was not listed as macro; so, it can not be run independently. Thanks "Dave Peterson" wrote in message ... Not that I know of. But if you can see the code for Manual_Input, maybe you can change it slightly: Option Explicit Sub Update_at_dayend() Call Manual_Input(ans:="8.25%") ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input(Optional ans As Variant = "") If ans = "" Then ans = InputBox(prompt:=" Enter Tax Rate for the area.") End If MsgBox ans ' the rest of the program End Sub And since the code is in the same workbook, I replaced Application.run with a simple Call. lashio wrote: Is there any VBA code for answering an InputBox Prompt of another macro. e.g. running macro "Update_at_dayend" Sub Update_at_dayend() Application.Run "Manual_Input" ' I need a code something like "At prompt, answer = 8.25%" End Sub Sub Manual_Input() Dim ans as variant ans = InputBox(prompt:=" Enter Tax Rate for the area." ' the rest of the program End Sub Thanks -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 12:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com