+ Reply to Thread
Results 1 to 9 of 9

Make a button to run a macro

Hybrid View

  1. #1
    Registered User
    Join Date
    09-13-2008
    Location
    Montreal
    MS-Off Ver
    Office XP
    Posts
    80

    Make a button to run a macro

    Hey all, Im kinda new to working with excel. I need to make a clickable button that when I click it it gives me a pre-determined text on another cell. Thanks for any help you can provide

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: I need to make a button

    Make a button. By default is is called CommandButton1.

    Double click and add line:
    Range("A1").Value = 3
    Private Sub CommandButton1_Click()
    Range("A1").Value = 3
    End Sub
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    slmi,

    Please read the Forum Rules about thread titles before starting your next thread.

  4. #4
    Registered User
    Join Date
    09-13-2008
    Location
    Montreal
    MS-Off Ver
    Office XP
    Posts
    80
    Sorry about the title,
    I also need to make that command button take some text that I will input on lets say A1 and copy past it on the text box that I have created in VB.

  5. #5
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671
    Private Sub CommandButton1_Click()
    Range("A1").Value = 3
    TextBox1.Value = Range("A1")
    End Sub

  6. #6
    Registered User
    Join Date
    09-13-2008
    Location
    Montreal
    MS-Off Ver
    Office XP
    Posts
    80
    when I enter the code above, I get the value 3 in the text box wich is great, but I also get the value 3 in the A1...what I need it to do is to take a text that I have already written in lets say sheet 3 A1 and put that info in the text box.

    thanks for the help guys

  7. #7
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: I need to make a button

    TextBox1.Value = Worksheets("Sheet3").Range("A1")

  8. #8
    Registered User
    Join Date
    09-13-2008
    Location
    Montreal
    MS-Off Ver
    Office XP
    Posts
    80
    thanks a lot that worked great, the only thing I forgot to mention is that I'm creating many command buttons, so I need the text to follow in the text box.
    So when I click on the first command button it will type what ever is in the A1and put it in the text box then when I click command button2 it takes whatever is in A2 and put it in the text box after the A1, not removing what was already in there.

    Thanks for all the help guys

  9. #9
    Registered User
    Join Date
    09-13-2008
    Location
    Montreal
    MS-Off Ver
    Office XP
    Posts
    80
    thanks a lot that worked great, the only thing I forgot to mention is that I'm creating many command buttons, so I need the text to follow in the text box.
    So when I click on the first command button it will type what ever is in the A1and put it in the text box then when I click command button2 it takes whatever is in A2 and put it in the text box after the A1, not removing what was already in there.

    Thanks for all the help guys

+ 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. insert row macro - relative to button
    By kevlux in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2008, 01:43 PM
  2. Is there a way to make a button appear once a macro is run?
    By fecurtis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2008, 04:30 PM
  3. Manipulating Macro Button in Standard Toolbar
    By DCSwearingen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2008, 11:57 AM
  4. Button to run a macro
    By billy2willy in forum Excel General
    Replies: 2
    Last Post: 04-25-2008, 09:00 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