12345

How to Add a Control Button to an Excel Spreadsheet

Tony Payne
Trying to add a button into an Excel spreadsheet does require a certain knowledge of Visual Basic, but if you already have a snippet of code to use, and just need to add a button, the help text in Excel may take a little reading and a lot of experimenting before you get it right.

Hopefully these guidelines will help to save a lot of the pain and frustration that go along with performing a task like this, and a picture paints a thousand words as they say, so I have added a number of screen prints to help make this task easier to follow.

STEP ONE

Open your Excel spreadsheet. Oh boy that was easy I hope! Now to work on adding the button.

STEP TWO

Buttons have behind them what is known as Active Controls. These are actions like clicking or moving the mouse, that can be used to make the program perform a function. In order to add a Button and it's controls, you first need to open the Controls Toolbox.

To do this, click on the View menu at the top of the screen, then on Toolbars, and lastly click on Controls Toolbox. A small window should now open in the spreadsheet.

STEP THREE

You are now ready to tell Excel that you want to create a Button (or other type of control as shown on the Control Toolbox). To do this, click on the 4th icon down in the left column in the toolbox. It should say Command Button.

You can also try hovering over the other icons to see what other options you can add to your spreadsheet. Once you get past the point where you successfully add your button, the options are endless - provided you learn Visual Basic that is.

Having told Excel that you want to create a Command Button, right click in the cell where you want the Button to appear and then click on CommandButton Object and then Edit. In my example I right clicked in cell B5.

A Button should now appear, ready for the button name/text to be edited. I called mine CLICK.

Having typed the name of your button, click anywhere outside of the image, and the button will be saved.

Should you have made a mistake and want to delete the button, click on it again and hit the Delete key on your keyboard. The button should disappear.

STEP FOUR

You are now ready to define the actions behind your button, which are done using the Visual Basic Editor.

Right Click on your button, and select View Code. The Visual Basic Editor will now open in a new window.

STEP FIVE

If you are copying code from another button to define the action that this button is to perform, highlight the outline code in the main panel of the Visual Basic Editor, delete the outline code that is automatically added, and copy/paste in the code for the actions you wish your button to perform.

If you want to define your own actions and to write your own Visual Basic code, then this is beyond the scope of this article, but I hope that I am able to help some people to get past what was a hurdle for me.

If this article has helped you, or if you have any feedback for me, please feel free to leave a comment. Feedback is always welcomed.

Published by Tony Payne

Tony Payne is a freelance writer who lives on the South Coast of England with his wife Debbie. He has worked in the IT Industry all his life, and has been writing on various sites for the last 10 years. T...  View profile

9 Comments

Post a Comment
  • Tony Payne4/29/2012

    This does work, but not with the latest versions of Excel where they have completely changed the menu structure. A horrible mess in my opinion, and that of everyone I know.

    The pictures are there, you have to click on the images for all 5 of them. It's the way that Yahoo! works unfortunately, otherwise I would have laid this out differently.

    Time to redo this on one of my blogs maybe for the latest versions of MS Office.

  • mr4/29/2012

    No pictures.
    No version of Excel this works with.
    Just another Excel site with stuff that doesn't work.

  • Tony Payne2/8/2012

    Having upgraded to Office 2007 I need to update this, as the process is completely different.
    Even using my own notes from here to remind myself of what to do, it took me an hour to get a button added in Excel 2007. I guess you love it or hate it, but so far 2007 is not impressing me none.

  • Tony Payne7/22/2010

    Six months after I wrote this article, and I had to consult it in order to repeat what I did before. Fortunately what I wrote makes sense - at least to me :) It's terrible when you can't understand your own instructions.

  • poddys1/20/2010

    I hope that this proves to be useful Rox. I am still frustrated that the images to illustrate it didn't come out, only the first one. There should be 5 and I took time to make sure that these showed the actions to take to make the process a lot clearer.

  • poddys1/19/2010

    You are welcome Jack.

  • Janet Hunt1/18/2010

    Great info... I often work with these speadsheets in my job.

  • poddys1/18/2010

    Thanks. Now all I have to do is to get the article images to display, there ought to be 5.

  • Jeffrey Weeks1/18/2010

    :) jeffrey

Displaying Comments

To comment, please sign in to your Yahoo! account, or sign up for a new account.