andrewb90
Well-known Member
- Joined
- Dec 16, 2009
- Messages
- 1,077
Hello all,
I have a custom right click for a series of ranges on on of my sheets. But I want to have a different range of cells with different right click options. is that possible?
here's a shortened version of my code:
I have a custom right click for a series of ranges on on of my sheets. But I want to have a different range of cells with different right click options. is that possible?
here's a shortened version of my code:
Code:
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")) 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
End If
End Sub