Search code examples
excelmenucell

Excel Cell Context Menu - Macro


I added a macro to the Excel Cell Context Menu.

This is the main code,

Private Sub Workbook_Open()
Dim NewControl As CommandBarControl
    Application.CommandBars("Cell").Reset
   Set NewControl = Application.CommandBars("Cell").Controls.Add
    With NewControl
      .Caption = "Inserir Data"
      .OnAction = "Module1.OpenCalendario"
      .BeginGroup = True
    End With
End Sub

Here you can see the result,

Excel Cell Context Menu

Ih there anyway to put this macro on the top of the menu?


Solution

  • Try:

    Set NewControl = Application.CommandBars("Cell").Controls.Add(before:=1)