Code:
Sub CreateShortcutMenuWithGroups()
' Create the shortcut menu.
Dim cmbRightClick As Office.CommandBar
On Error Resume Next
CommandBars("cmdFormFiltering").Delete
Set cmbRightClick = CommandBars.Add("cmdFormFiltering", msoBarPopup, False, True)
With cmbRightClick
'.Controls.Add msoControlButton, 141, , , True 'find
'.Controls.Add msoControlButton, 19, , , True 'copy
.Controls.Add(msoControlButton, 210, , , True).BeginGroup = True 'new group: sort asc
.Controls.Add msoControlButton, 211, , , True 'sort desc
.Controls.Add(msoControlButton, 605, , , True).BeginGroup = True 'new group filter: clear filter
.Controls.Add msoControlButton, 640, , , True 'Filter by Selection
.Controls.Add msoControlButton, 3017, , , True 'Filter Excluding Selection
.Controls.Add msoControlButton, 10077, , , True 'Filter equals xx
.Controls.Add msoControlButton, 10078, , , True 'Filter not equal to xx
.Controls.Add msoControlButton, 10079, , , True 'Filter beings with xx
.Controls.Add msoControlButton, 12696, , , True 'Filter does not beings with xx
.Controls.Add msoControlButton, 10080, , , True 'Filter contains xx
.Controls.Add msoControlButton, 10081, , , True 'Filter does not contains xx
.Controls.Add msoControlButton, 10082, , , True 'Filter ends with xx
.Controls.Add msoControlButton, 10083, , , True 'Filter ends with xx
.Controls.Add msoControlButton, 12697, , , True 'Filter does not ends with xx
.Controls.Add msoControlButton, 10062, , , True 'between
End With
Set cmbRightClick = Nothing
End Sub