Add commandbutton on any excel sheets

Doflamingo

Board Regular
Joined
Apr 16, 2019
Messages
238
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 ?
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,496
Office Version
365, 2010
Platform
Windows
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
 

Doflamingo

Board Regular
Joined
Apr 16, 2019
Messages
238
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
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,496
Office Version
365, 2010
Platform
Windows
Whatever works for you is the right thing. I was happy to help. Thanks for the feedback.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,865
Messages
5,507,801
Members
408,647
Latest member
gazmoz17

This Week's Hot Topics

Top