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
- Introduction to Visual BasicIf you're an aspiring computer programmer, Visual Basic should be the first language you attempt to learn.
- Visual Basic WinSock TutorialThis is a tutorial about the Winsock control in Visual Basic. The tutorial is based on a real-time chat application as example, that shows the functionality of Winsock Control.
- How to Find Information on an Excel Spreadsheet It's easy to find information on an Excel spreadsheet once you know what you are looking for and how to sort the spreadsheet in a way that groups data together. I can now sort it to group specific types of information...
- Visual Basic: Create a Text SpammerIn this article, I will walk you through creation of a text spammer, utilizing the "sendkeys" command in Visual Basic.
- Working with Access VBA
- FROM the COMMAND PROMPT:
- Tips on Deepening Your Use of Microsoft Word - Introduction to Word Macros
- Customized 2003 Outlook Forms Tutorial
- How to Optimize that Older Windows Computer - Without Upgrading to a New One!
- The Best Tutorial Sites for Visual Basic.NET
- How to Use Win32API in Visual Basic





9 Comments
Post a CommentThis 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.
No pictures.
No version of Excel this works with.
Just another Excel site with stuff that doesn't work.
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.
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.
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.
You are welcome Jack.
Great info... I often work with these speadsheets in my job.
Thanks. Now all I have to do is to get the article images to display, there ought to be 5.
:) jeffrey