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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,493
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,493
Office Version
365, 2010
Platform
Windows
Whatever works for you is the right thing. I was happy to help. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,000
Messages
5,484,113
Members
407,431
Latest member
kalvinswisher

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top