J & R Solutions

"making Excel work for you!"

Search

Latest news

June 01: Halfway through 2007 and finally had time to tidy up our web site. Hope you like the changes and whilst you are here why not check out the Excel products we are offering

May 28: Opened our new Forum for membership. Free help o all our products and your Excel questions

Links:

Add a button to your worksheet

First you need to make sure that the Developer Tab is available
Click the 
Microsoft Office Button, and then click Excel Options.

 Click Popular, and then select the Show Developer tab in the Ribbon check box.

 NOTE   The Ribbon is part of the Microsoft Office Fluent user interface

Probably the most commonly created control object for worksheets is the button. This is because the most common use of buttons is to run macros which you have associated with a workbook or display a UserForm. You can insert buttons in your worksheet by use of the Button tool on the Forms toolbar:

1. Click on the Button tool.

2. Click in your workbook where you want a corner of the button to appear, but don't release the mouse button.

3. Move the mouse to specify the size of the button you want.

4. Release the mouse button.

If you are using Microsoft Excel 2007, there is no Forms toolbar. Instead, you must use the Developer tab of the ribbon and then click Insert in the Controls group. The resulting palette shows a number of different controls; you should click the Button tool, and then follow the four steps listed previously.

Excel immediately displays the Assign Macro dialog box, offering you the opportunity to assign a macro to the button. You will see that the dialog box shows a list of previously defined macros, along with a suggested name for the macro to be assigned to this button. The suggested name is comprised of the default name of the button itself (something like Button1) combined with the action that will start the macro (Click). This macro name (Button1_Click) will appear very familiar to people that have programmed in Visual Basic before, since it conforms to the standard way of naming event handlers. (Event handlers are nothing but programming code designed to handle a specific event, such as an object—like a button—being clicked with the mouse.

To finish with the Assign Macro dialog box, select a macro you want assigned to this new button and then click on OK. You can then change the title appearing on the button by clicking your mouse within the button text and entering a new title.

Once the button is finished in this manner, the macro associated with this button will be run whenever anyone clicks on it with the left mouse button. If you use the right mouse button instead, you will see a menu that allows you to delete the button or change the macro assigned to the button.

ActiveX controls can be added from the Controls ToolBox or th Excel 2007 Developer tab as above. These are more complex than Forms Controls and have more properties and can contain code.