+ Reply to Thread
Results 1 to 5 of 5

Attach VBA to a Button

  1. #1
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Devon, England
    MS-Off Ver
    Excel 2003
    Posts
    128

    Attach VBA to a Button

    hi folks,

    I have the following code that I want to attach to a button, but am at a loss of how to?

    Sub sbClearCellsOnlyData()
    Range("A1:D5").ClearContents
    End Sub

    Nick

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Attach VBA to a Button

    you could do it with a shape....insert a shape (Box, Oval). then right click on the shape and "Assign Macro". A list of macros will come up and choose your macro...This is for 2010....not sure in 2003....
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Devon, England
    MS-Off Ver
    Excel 2003
    Posts
    128

    Re: Attach VBA to a Button

    Thanks, that's sorted it

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Attach VBA to a Button

    glad I could help....

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Attach VBA to a Button

    you just create a button from the forms tool bar
    right click it assign macro
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Attach Hyperlink to textbox or control button?
    By cwashburn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-27-2013, 04:11 AM
  2. trying to attach a macro to a button
    By crazyhick in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2010, 08:19 AM
  3. how to attach a up and down arrow to a spin button
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2010, 11:36 AM
  4. I cannot find the [Browse] button to attach a post?
    By Joe Miller in forum Excel General
    Replies: 2
    Last Post: 03-31-2009, 09:20 AM
  5. [SOLVED] in this version I can not attach a Macro to a Button
    By Hussam Bachat in forum Excel General
    Replies: 3
    Last Post: 07-13-2005, 05:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1