

However, the number does not have to be surrounded by double quotation marks like if you were inputting text for the argument. Look closely in the above code and you will see this. Note: the name of the macro and the argument must be surrounded by single quotation marks. That is how you pass a numeric argument to the macro simply put a space after the name of the macro and type the number.

Notice the 5 after the name of the macro. The name of the macro will not appear in the window so we must type it in under where it says Macro name. Note: the text is surrounded by double quotation marks and then the entire thing is surrounded by single quotation marks. Type in the name of the macro and then a space and then the value that you want to send to the macro. We must type in the name of the macro and then also the value for the argument. Hit Alt + F8 to get to the Run Macro window: When you go to run this macro from the worksheet Excel interface, you will actually not see it in the list of available macros. This macro accepts a value in the message variable and then outputs it into a message box pop-up. 'output a message that is given to this macro Here is our sample macro: Sub show_msg(message) To allow a macro to accept a value, you simply type a name for that value between the parentheses at the top of the macro. Notes Create the Macro to Accept the Value Sections:Ĭall the Macro from a Button or Other Object/Shape This is different than passing a value from one macro to another.
#Make a pass in a text how to
How to pass arguments and values to macros called from worksheets, buttons, and anything else from the Excel interface.
