Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Adding Buttons to Your Worksheet.

Adding Buttons to Your Worksheet

by Allen Wyatt
(last updated August 1, 2015)

3

Probably the most commonly created control object for worksheets is the lowly button. This is because the most common use of buttons is to run macros which you have associated with a workbook. You can insert buttons in your worksheet by use of the Button tool. Follow these steps:

  1. Display the Developer tab of the ribbon.
  2. Click Insert in the Controls group. You'll see a small palette of items you can insert in your document.
  3. Click on the Button tool.
  4. Click in your workbook where you want a corner of the button to appear, but don't release the mouse button.
  5. Move the mouse to specify the size of the button you want.
  6. Release the mouse button.

Excel immediately displays the Assign Macro dialog box, offering you the opportunity to assign a macro to the button. Notice that the dialog box presents 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 complete your work 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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10485) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Adding Buttons to Your Worksheet.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Inserting the Date in a Header or Footer

Need today's date in the header or footer of your document? Here's how to get it there easily.

Discover More

Shortcut for AutoCorrect Dialog Box

There is no built-in keyboard shortcut that will display the AutoCorrect dialog box. This doesn't mean that there aren't ...

Discover More

Changing Fonts in Multiple Workbooks

If you need to change fonts used in a lot of different workbooks, the task can be daunting, if you need to do it ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Counting Commas in a Selection

If you have a range of cells in which you want to count all the commas, there are several ways you can derive the figure ...

Discover More

Determining an ANSI Value in a Macro

Need to know the character code used for a particular character? In a macro you can use the Asc function to determine the ...

Discover More

Expiration Date for Excel Programs

If you use Excel to create a macro-based application, you may want to make sure that your programs cease working after a ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 3?

2018-09-11 13:31:56

Harry M

Cool tip! Thanks!


2018-06-12 05:02:59

Willy Vanhaelen

@Dale

Private Sub ALL_Click()
Call ADA_Click
Call ARDR_Click
Call BAT_Click
' etc...
End Sub

Assign this macro to a "Run All" button and you are done.


2018-06-11 20:01:38

Dale

i followed your instructions above. Now I have 27 buttons that do the same thing of copying rows based on specified criteria. All of them work correctly. Is there a way to have one button that runs all of the others at once when I I click on it. The following is part of my code. Sorry I have no idea of what I am talking about.

Private Sub ADA_Click()

a = Worksheets("DATA").Cells(Rows.Count, 1).End(xlUp).Row


For i = 2 To a


If Worksheets("DATA").Cells(i, 2).Value = "BTC-ADA" Then


Worksheets("DATA").Rows(i).Copy
Worksheets("ADA").Activate
b = Worksheets("ADA").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("ADA").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("DATA").Activate


End If
Next

Application.CutCopyMode = False

ThisWorkbook.Worksheets("DATA").Cells(1, 1).Select


End Sub
Private Sub ARDR_Click()

a = Worksheets("DATA").Cells(Rows.Count, 1).End(xlUp).Row


For i = 2 To a


If Worksheets("DATA").Cells(i, 2).Value = "BTC-ARDR" Then


Worksheets("DATA").Rows(i).Copy
Worksheets("ARDR").Activate
b = Worksheets("ARDR").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("ARDR").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("DATA").Activate


End If
Next

Application.CutCopyMode = False

ThisWorkbook.Worksheets("DATA").Cells(1, 1).Select


End Sub



Private Sub BAT_Click()

a = Worksheets("DATA").Cells(Rows.Count, 1).End(xlUp).Row


For i = 2 To a


If Worksheets("DATA").Cells(i, 2).Value = "BTC-BAT" Then


Worksheets("DATA").Rows(i).Copy
Worksheets("BAT").Activate
b = Worksheets("BAT").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("BAT").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("DATA").Activate


End If
Next

Application.CutCopyMode = False

ThisWorkbook.Worksheets("DATA").Cells(1, 1).Select


End Sub


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.