Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Dim ContextMenu As CommandBar
Dim ctrl As CommandBarControl
Application.CommandBars("Cell").Reset
If Intersect(Target, Range("E89:R106,E108:R125,E127:R144,E146:R163,E194:R207,E165:R167,E169:R169,E171:R171,E173:R173,E175:R175,E177:R177,E179:R179,E181:R181,E183:R183,E185:R185,E187:R187,E189:R189,E191:R191")) Is Nothing Then
Application.CommandBars("Cell").Reset
Exit Sub
Else
Set ContextMenu = Application.CommandBars("Cell")
For Each ctrl In ContextMenu.Controls
ctrl.Delete
Next ctrl
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=1)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "RTO"
.FaceId = 2113
.Caption = Sheets("Settings").Range("K16") & " " & Sheets("Settings").Range("L16")
End With
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=2)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "RTO_OTHER"
.FaceId = 1845
.Caption = Sheets("Settings").Range("K17") & " " & Sheets("Settings").Range("L17")
End With
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=3)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "RTO_NOTE"
.FaceId = 916
.Caption = "CUSTOM NOTES"
'.Font.Color = vbWhite
'.Interior.Color = vbBlack
End With
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=4)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "RTO_JURY"
.FaceId = 2131
.Caption = Sheets("Settings").Range("K18") & " " & Sheets("Settings").Range("L18")
End With
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=5)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "RTO_MATERNITY"
.FaceId = 2777
.Caption = Sheets("Settings").Range("K19") & " " & Sheets("Settings").Range("L19")
End With
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=6)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "RTO_EVENT"
.FaceId = 353
.Caption = Sheets("Settings").Range("K20") & " " & Sheets("Settings").Range("L20")
End With
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=7)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "RTO_CUSTOM"
.FaceId = 484
.Caption = Sheets("Settings").Range("K21") & " " & Sheets("Settings").Range("L21")
End With
With ContextMenu.Controls.Add(Type:=msoControlButton, before:=8)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "CLEAR"
.FaceId = 2087
.Caption = "*!CLEAR REQUESTS!*"
End With
End If
End Sub