Visual Basic for Applications, or VBA, is a programming language packaged with Microsoft Excel 2010, that allows you to write code that can manipulate your spreadsheet. Amongst other things, VBA can have a text box appear on the screen, in front of the spreadsheet. This box can contain a message for your users, but they can also enter text into the box if they need to. By default, the box appears with a blinking cursor, whether there is text in the box or not, and there isn't a setting to change this. However, you can create another hidden text box in the VBA console, and shift the focus to this box, making it appear as if the cursor is no longer there.
- Skill level:
Other People Are Reading
Open the Excel 2010 file that you want to work with. Press "Alt" and "F11." The VBA console will open up in a separate window.
Select the Userform that holds your textbox from the list of items on the left side of the VBA console. Double-click the userform to make it appear in the large white space on the right side of the console.
Click on the Userform on the right side of the console. Move your cursor to the middle of the bottom of the box. Click and hold the mouse button, then drag the bottom of the box down about an inch on your screen, making the box just a bit bigger. Release the mouse button.
Click the "View" menu at the top of the screen. Select "Toolbox" from the drop-down menu. Click the textbox icon on the toolbox. It is the third icon from the left along the top row and is labelled "ab." Then click anywhere in the area of the textbox that you added, and a small textbox will appear.
Look at the left side of the VBA console window and find the "Name" field under the "Properties" heading. If this is just the second textbox in the project, the name field will read "TextBox2." However, if there were other textboxes in the project, you will need to write down the name, as you will need it later.
Close the toolbox, and select the userform again. Move your mouse to the middle of the bottom of the form, and drag it up, hiding the new text box.
Right-click the userform on the list on the left side of the console. Choose "View code." Click the white space on the right side of the screen to place your cursor there. Enter the following code into the space:
Private Sub UserForm_Activate()
Change "TextBox2" to whatever name Excel assigned to the new textbox you created.
Close the Excel VBA console by clicking the "X" in the upper-right corner of the window. When you run your VBA macro to display the textbox, the cursor will no longer appear.