Page 748 - Excel 2013 All-in-One For Dummies
P. 748
730 Using the Visual Basic Editor
In this function, only the prompt argument is required with the rest of the arguments being optional. The prompt argument specifies the message that appears inside the Input dialog box, prompting the user to enter a new value (or in this case, a new company name). The prompt argument can be up to
a maximum of 1,024 characters. If you want the prompt message to appear on different lines inside the dialog box, you enter the functions Chr(13) and Chr(10) in the text (to insert a carriage return and a linefeed in the message, respectively).
The optional title argument specifies what text to display in the title bar of the Input dialog box. If you don’t specify a title argument, Excel displays the name of the application on the title bar. The optional default argument speci- fies the default response that automatically appears in the text box at the bottom of the Input dialog box. If you don’t specify a default argument, the text box is empty in the Input dialog box.
The xpos and ypos optional arguments specify the horizontal distance from the left edge of the screen to the left edge of the dialog box and the vertical distance from the top edge of the screen to the top edge of the dialog box. If you don’t specify these arguments, Excel centers the input dialog box hori- zontally and positions it approximately one-third of the way down the screen vertically.
The helpfile and context optional arguments specify the name of the custom Help file that you make available to the user to explain the workings of the Input dialog box as well as the type of data that it accepts. As part of the process of creating a custom help file for use in the Excel Help system,
you assign the topic a context number appropriate to its content, which is then specified as the context argument for the InputBox function. When you specify a help file and context argument for this function, Excel adds a Help button to the custom Input dialog box that users can click to access the custom help file in the Help window.
Before you can add the line of code to the macro with the InputBox function, you need to find the place in the Visual Basic commands where the line should go. To enter the Mind Over Media text into the active cell, the Company_Name macro uses the following Visual Basic command:
ActiveCell.FormulaR1C1 = “Mind Over Media”
To add interactivity to the macro, you need to insert the InputBox function on a line in the Code window right above this ActiveCell.FormulaR1C1 statement, as follows:
1. Position the insertion point in the Code window at the beginning of the ActiveCell.FormulaR1C1 statement and press Enter to insert a new line.