Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

To link that tabs command bar to a right-click in any cell, enter the following code in the private module of ThisWorkbook

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)       Dim cCont As CommandBarButton       On Error Resume Next       Application.CommandBars("Cell").Controls("Sheet Index").Delete       On Error GoTo 0       Set cCont = Application.CommandBars("Cell").Controls.Add _       (Type:=msoControlButton, Temporary:=True)       With cCont         .Caption = "Sheet Index"         .OnAction = "IndexCode"       End With End Sub