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 ?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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
 
Upvote 0
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
 
Upvote 0
Whatever works for you is the right thing. I was happy to help. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,947
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top