Chewyhairball
Active Member
- Joined
- Nov 30, 2017
- Messages
- 312
- Office Version
- 365
- Platform
- Windows
Hi Folks
I have the following piece of code to create custom right click menu linked to macros.
I went to adapt it to work when i right clicked on cell b3 but it does not seem to work.
The only thing i have found is that it works on a range or single cell as long as it is within a named table, if i try to use it for any other cells it doesn't work.
I am fairly sure I have used it before ( not in a table ) and it worked but i cant find the spreadsheet to have a look what is different.
any ideas would be most welcome
I have the following piece of code to create custom right click menu linked to macros.
I went to adapt it to work when i right clicked on cell b3 but it does not seem to work.
The only thing i have found is that it works on a range or single cell as long as it is within a named table, if i try to use it for any other cells it doesn't work.
I am fairly sure I have used it before ( not in a table ) and it worked but i cant find the spreadsheet to have a look what is different.
any ideas would be most welcome

VBA Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _ Cancel As Boolean)
Dim a As Object
For Each a In Application.CommandBars("list range popup").Controls
If a.Tag = "a" Then a.Delete
Next a
If Not Application.Intersect(Target, Range("d7:d100")) _
Is Nothing Then
With Application.CommandBars("list range popup").Controls _
.Add(Type:=msoControlButton, before:=6, _
Temporary:=True)
.Caption = "Move Selected Cells"
.OnAction = "Move_Selected_Cells"
.Tag = "a"
End With
End If