Cell context menu - Sort

Formula11

Active Member
Joined
Mar 1, 2005
Messages
468
Office Version
  1. 365
Platform
  1. Windows
I've been using this to modify the context menu (right-click) in Excel.

The method below is when in Page Break preview, which is different to Normal View. "+3" is the difference, at least for Office 365.

Not sure if Sort was available initially, as I may have deleted before.
Trying to reinstate Sort with the last line/s of code but not working.


VBA Code:
Sub add_del_context_menu()
    Dim context_menu As CommandBar
    'Page Break Preview
    '------------------
    Application.CommandBars(Application.CommandBars("Cell").Index + 3).Reset
    Set context_menu = Application.CommandBars(Application.CommandBars("Cell").Index + 3)
    On Error Resume Next
    'varies for each Excel version
    context_menu.FindControl(ID:=25536).Delete 'Smart Lookup
    context_menu.FindControl(ID:=3181).Delete 'Insert...
    context_menu.FindControl(ID:=292).Delete 'Delete...
    context_menu.FindControl(ID:=3125).Delete 'Clear Contents
    context_menu.FindControl(ID:=24508).Delete 'Quick Analysis
    context_menu.FindControl(ID:=31402).Delete 'Filter
    context_menu.FindControl(ID:=34003).Delete 'Get Data from Table/Range
    context_menu.FindControl(ID:=1966).Delete 'Pick From Drop-down List
    context_menu.FindControl(ID:=13380).Delete 'Define Name
    
    Application.CommandBars.FindControl(ID:=31435).Enabled = True 'Try 1
    Application.CommandBars.FindControl(ID:=31435 + 3).Enabled = True 'Try 2
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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