Add Command Button to an Excel Worksheet

This was a request from a reader who wanted to know how to add and use a command button that was controlled from a worksheet in Excel.

Lets assume we will use a worksheet called “Sheet1”.  If you don’t have the image-1Visual Basic tool bar open then first of all let’s open that so we can see it.  Go to View > Toolbars and then select Visual Basic.  This will open the tool bar, and you can then drag this to the menu at the top.  Next click the Control Toolbox button.  This is represented by a small hammer and screwdriver icon (as shown in the image to the right).  Clicking this will activate the Control Toolbox that will allow us to insert a command button into the worksheet.  The Control Toolbox can also be dragged and inserted into the menu at the top.

Inserting the Command Button

OK, third of the way now.  On the Control Toolbox is a small icon that looks like a grey
rectangle.  If you hover over it image2with the mouse a tooltip will appear that says Command Button.  Clicking this will cause a small box to appear (it means you are in Design Mode), and you will notice that the mouse cursor has changed to crosshairs.  All you do, is click with the left mouse button anywhere on the worksheet and draw a rectangle with it.  In my example I have made the button nice and big. This will then place your command button, and don’t worry as it can be moved from this position very easily simply by clicking and dragging with the mouse whilst in design mode.  You can click in out of design mode by clicking on the button represented by a triangle,ruler and pencil icon.  So, now there is a command button on your worksheet.  If you come out of design mode you will see that you can click button, but it doesn’t do anything!

Getting the Command Button to do Something

Finally, you need to give the command button something to do when you click it!  For this example, I will get to display a message box saying “Hello World”.  If you have come out of design mode, click the back into it by clicking on the icon with a triangle, image3ruler, and pencil displayed.  Once you have done this, double click on the command button and this will open a new window, which will be the Visual Basic Environment (VBE), it is from here that code is run from.  In the right hand pane of the VBE there is some text already entered for you.  It should say something like

Private Sub CommandButton1_Click()

End Sub

click between these two lines in the blank space.  And type the following:
MsgBox "Hello World"
This tells the code to show a messge box that will say “Hello World”.  Now you have typed that, click back into the worksheet and then come out of design mode.  You can also tell if you are in design mode by hovering over the command button.  If you are in design mode, the mouse will turn to cross hairs as you hover over the button.

image4Now that you have come out of design mode click the button, and you should get a message box pop up!  So now, you could put your code where you had written
MsgBox "Hello World"

and this should run whenever you click the button.

2,841 thoughts on “Add Command Button to an Excel Worksheet

  1. genolyze

    Your style is very unique in comparison to other folks I have read stuff from. Thank you for posting when you have the opportunity, Guess I will just book mark this web site.

  2. sports news

    Spot on with this write-up, I honestly believe this web site needs
    a great deal more attention. I’ll probably be back again to
    read more, thanks for the info!

  3. Apps Para Assistir Tv No Android

    Ponto IPTV a melhor programacao de canais IPTV do Brasil, filmes, series, futebol, lutas, shows, documentarios em alta definicao de imagem e som em SD, HD, FULL HD, 4K. compativel com todos aparelhos do mercado Brasileiro.

  4. harga

    Everything is very open with a precise explanation of the challenges. It was really informative. Your site is very helpful. Many thanks for sharing!

  5. toko online 88

    I wanted to thank you for this fantastic read!! I absolutely loved every little bit of it. I have got you saved as a favorite to look at new things you post…

  6. Keluaran Sgp

    hey there and thank you for your information – I’ve certainly picked up anything new from right here.
    I did however expertise several technical issues using this web site, as I experienced to reload the site many times previous to I could get it to load correctly.
    I had been wondering if your web host is OK? Not that I’m complaining,
    but sluggish loading instances times will very frequently affect your placement in google and could damage
    your quality score if ads and marketing with Adwords. Anyway I’m adding this RSS to my e-mail and could look
    out for a lot more of your respective interesting content.
    Make sure you update this again very soon.

  7. vivo slot

    I would like to thank you for the efforts you have put in writing this website. I am hoping to check out the same high-grade content from you in the future as well. In truth, your creative writing abilities has inspired me to get my own website now 😉

  8. human hair wigs

    human hair wigs
    I am an active 21 year old, who already has chronic back pain. I have
    tried absolutely EVERYTHING to try to help with the pain. The
    only suggestion that they have for me anymore is to start a regimen of narcotics.
    When an aircraft flies at a ground level approximately at or below the length of the aircraft’s wingspan or helicopter’s rotor diameter,
    there occurs, depending on airfoil and aircraft design, an often noticeable ground
    effect. This is caused primarily by the ground
    interrupting the wingtip vortices and downwash behind the
    wing. When a wing is flown very close to the ground, wingtip vortices are unable to form effectively due to the obstruction of the ground.

    cheap wigs The same year, the sci fi/drama movie Inalienable, written by Star Trek alumnus
    Walter Koenig, was released. Sirtis said of her role,
    “I actually play the Deputy Attorney General of the United States, so I’m a bad guy, a mean lawyer, which was fantastic.”[16]The direct to
    DVD sequels Green Street 2 and The Grudge 3, featuring Sirtis, were released in 2009.
    She co starred in the British movie 31 North 62 East as the prime minister’s top aide; it had
    a limited theatrical release in the UK. cheap wigs

    cheap wigs In 1952, Billingsley had her first role as a guest star, in an episode of The Abbott and Costello Show.In 1955,
    she won a co starring role in the sitcom Professional Father, starring Stephen Dunne and
    Beverly Washburn. The series lasted one season. The following year, Billingsley
    had a recurring role on The Brothers (with Gale Gordon and Bob Sweeney),
    as well as an appearance with David Niven on his anthology series
    Four Star Playhouse. cheap wigs

    human hair wigs The movement changes and revamps came at the
    beginning of 2017 while the new gear wasn even given an eta and literally no
    new content was shown. Most of the pc community began to think they had moved everything into making the game console friendly to
    release a console port, but they denied this.
    Then, 6 months after no updates, they released a console port for xbone and ps4.
    human hair wigs

    Lace Wigs Isn’t “Reality TV” kind of an Oxymoron. Glad to see
    you’re still here. Sorry, but there is no truth when it comes to reality TV.
    I moved into a flat about 8/9 years ago. Started getting official red demand
    letters from a debt collection agency addressed to the former tenant, as well as letters addressed “to the occupier”
    asking for information about the whereabouts of the former owner.
    I contacted them and explained that the tenant had moved on. Lace Wigs

    wigs On December 7, 2014, the prospering note “Who Needs You” was found in an Apple Inc.
    Accompanied with the announcement was a new 86 second track titled “Buddy”The Orwells sound like several
    great US garage rock bands spliced together.

    The metronomic four chord attack of Who Needs You is pure early Strokes, while the single
    Dirty Sheets has the bluesy lilt of The Black Keys. wigs

    human hair wigs He wanted to the game itself. He really enjoys the interactive aspect now that we have done the playable pacman costume, smash bros costume, and poke’mon theater costume.
    I totally agree with him there, it is so much fun being able
    to have people interact with the costume and being all lit up is
    great too!. human hair wigs

    wigs It wasn’t sunscreen that we had rubbed all over our faces but rather icy hot.

    Icy hot all over my face, in my nose, and literally in my eyes.
    We’re lucky we didn’t go blind. Open mouth with upper teeth.
    Replaced wig. Ball jointed composition body. To collect scrap metal one has to keep their eyes open because
    you never know when you will find something that you can use.
    The perfect days to look for scrap is the day of trash collection. Make sure
    you start out hours earlier than the time your neighborhood trash disposal service provider pick up trash.

    360 lace wigs Guest, McKean and Shearer made a cameo appearance
    as the Folksmen in the 1992 film The Return of Spinal Tap, which documented the latter group’s real life reunion concert
    at Royal Albert Hall in London. When the trio subsequently toured as Spinal
    Tap during 2001, they would occasionally perform in the guise of the Folksmen as an ostensible “opening act”; not all of the audiences appreciated (or even understood) this in joke, with
    one appearance in New York City reportedly being booed by a restless audience.

    Of this twist, Shearer once stated: “You can think you’re in control of the amusing notion of the wrong act opening for a rock band but when you actually find yourself being the wrong act, it doesn’t feel any better.”[3] In a 2009 interview,
    Guest reflected further on the phenomenon:. 360 lace wigs

    Lace Wigs It essentially covers the first arc of the series up to the prison laboratory, and ends with Ed/Al
    starting their journey for the philosopher stone in earnest.
    They took some liberties to make it a coherent, self contained story and cut out some stuff that doesn get
    answered until waaaaaay later, but all in it does a really good job of staying fairly close to the source material for
    a one shot live action.It not a 1:1 of the anime/manga but
    with real people, but no live action is (or even feasibly could be), and it not nearly as bad as people are griping about.
    It ends up using a lot of small things from the manga,
    but without following through with it. Lace Wigs

    wigs What we call a fig (a structure called the syconium) is more inverted flower than fruit, with all its reproductive parts located inside.
    After a female fig wasp flies over from the fig
    plant she emerged from, she must travel to the center of the syconium to
    lay her eggs. To get there, she climbs down through a narrow
    passage called the ostiole. wigs

    human hair wigs I heard a story once that Lou and the
    Director were going over a scene before shooting and the
    Director gave him his directions telling him to go break through the wall.
    Director yells action and Lou breaks though the wall like a beast, director yells cut and
    Lou comes over all pissed off at the Director.
    He says that he got all cut up, the prop guys did a bad job of building
    the wall and it wasn safe. human hair wigs

    360 lace wigs He does what I ask, if he doesn he put in time out or loses a privilege.
    It really that simple. Parenting isn always
    easy, but it also just not that hard.. Malolo loses and Bradley is sent to GI.
    We say just for example that Chelsea gets voted out.
    First Tribal Council vote outs: 3 People that haven gone to tribal yet: Morgan, Bradley, Chris, Angela, Domenick,
    WendellMalolo loses again and Bradley is sent home.

    360 lace wigs

    cheap wigs human hair It was bound to be thrilling. What I didn’t know going in, though, was just how
    much Big Little Lies would touch me. But the show was both gripping and haunting in the ways it navigated the overarching threat men pose to women and in the ways those women alternately pull apart and bind
    together on their own. cheap wigs human hair

    360 lace wigs Yes, formula fed babies are healthly and happy.
    It is just that breastmilk will ensure that your child FULLEST (God given)potential will be met, in a number of ways.
    That doesn mean you are a bed mom if you decide to use formula.
    Altezza pu essere raggiunto sollevando delicatamente con il pennello.
    La parrucca pu essere uno stile pi vicino alla testa per un aspetto pi piatto.

    Se aggiunto pienezza richiesto, eseguire delicatamente il pettine poi lisciare la superficie
    dei capelli sopra il backcombing 360 lace wigs.

  9. agen slot vivoslot

    You’re so cool! I do not think I’ve truly read through something like this before. So wonderful to discover somebody with genuine thoughts on this issue. Really.. thank you for starting this up. This website is something that is needed on the web, someone with some originality!


    Oh my goodness! Awesome article dude! Thank you so much, However I am experiencing problems with your RSS. I don’t understand why I am unable to join it. Is there anybody getting identical RSS problems? Anyone that knows the solution can you kindly respond? Thanx!!

  11. agen judi vivoslot

    Your style is unique in comparison to other folks I’ve read stuff from. Thank you for posting when you have the opportunity, Guess I will just bookmark this blog.

  12. togelonline

    I blog frequently and I seriously appreciate your content. Your article has really peaked my interest. I’m going to book mark your site and keep checking for new information about once a week. I opted in for your RSS feed too.

  13. vivoslot android

    I blog frequently and I seriously thank you for your content. The article has really peaked my interest. I am going to take a note of your blog and keep checking for new information about once per week. I subscribed to your RSS feed as well.

  14. download vivoslot apk

    I’m amazed, I have to admit. Rarely do I come across a blog that’s equally educative and engaging, and let me tell you, you have hit the nail on the head. The issue is something which not enough people are speaking intelligently about. I am very happy that I stumbled across this in my search for something concerning this.

  15. dingdong togel 24d

    You’ve made some really good points there. I checked on the net for more information about the issue and found most individuals will go along with your views on this website.

  16. jasa backlink manual

    I was curious should you ever considered changing the design of the site? Its extremely well written; I enjoy what you’ve got to be able to say. But maybe an individual could a little considerably more when it comes to content so folks could connect with that better. You have an horrible lot of text regarding only having one or perhaps 2 pictures. You may may space it out much better?

  17. dingdong 24d

    I blog often and I seriously appreciate your content. This article has truly peaked my interest. I am going to bookmark your site and keep checking for new details about once a week. I opted in for your Feed as well.

Comments are closed.