Add commandbutton on any excel sheets
Results 1 to 4 of 4

Thread: Add commandbutton on any excel sheets
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Apr 2019
    Posts
    192
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Add commandbutton on any excel sheets

    Hi all,

    Does anybody know how to add a commandbutton on any existing excel sheet ?

    Imagine I have a commandbutton with that code

    Code:
    Sub auto_open()
      F_Onglets.Show
    End Sub
    How to see this command button on any excel sheet, already existing and the new ones created ?

  2. #2
    Board Regular igold's Avatar
    Join Date
    Jul 2014
    Location
    Delray Beach, FL, USA
    Posts
    2,331
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Add commandbutton on any excel sheets

    This would add a button that will run your code "auto_open" to the activesheet. You can change the name, size, placement, text, color, etc, as you see fit...

    Code:
    Sub AddButton()
    
    
        ActiveSheet.Buttons.Add(600, 30, 120, 30).Select
        With Selection
            .Name = "CommandButton"
            .OnAction = "auto_open"
            .Characters.Text = "Show F_Onglets"
            .Font.Color = RGB(0, 100, 200)
            .Font.Size = 16
        End With
        
    End Sub
    ​igold

    I'm a drinker with a coding problem...

    All code is written with Excel 2010 - Please test all code on a backup copy of your data.


  3. #3
    Board Regular
    Join Date
    Apr 2019
    Posts
    192
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Add commandbutton on any excel sheets

    Hi @igold

    Many thanks for your reply. Indeed it makes appear a commandbutton on the active sheet.

    But I changed my mind and I finally decided to personalize the ribbon to make appears easily the macros the most used on the active sheet.

    Many thanks for your time and your help

    Kind regards

  4. #4
    Board Regular igold's Avatar
    Join Date
    Jul 2014
    Location
    Delray Beach, FL, USA
    Posts
    2,331
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Add commandbutton on any excel sheets

    Whatever works for you is the right thing. I was happy to help. Thanks for the feedback.
    ​igold

    I'm a drinker with a coding problem...

    All code is written with Excel 2010 - Please test all code on a backup copy of your data.


Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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