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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

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,106,540
Messages
5,511,925
Members
408,868
Latest member
AndrewLeonard

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top