Hi,

A nice to have: selecting text from a string in a cell and add it to a list to be used as a keyword in conditional formatting.

I've figured out how to add a custom button to the Formula Bar right click menu. The problem now is that the sub procedure assigned to the custom button is not executed when selected. In the sample code below I've assigned a sub procedure to display a userform. Using the default Cut function does cut the selected text, so what needs to be done to get the assigned sub procedure to be executed?

Any suggestions?

Many thanks.
Izak

Sub AddToFormBarMenu()

Dim ContextMenu As CommandBar
Dim MySubMenu As CommandBarControl

' Delete the controls first to avoid duplicates.
Call DeleteFromFormBarMenu

' Set ContextMenu to the Formula Bar context menu.
Set ContextMenu = Application.CommandBars("Formula Bar")

With ContextMenu.Controls.Add(Type:=msoControlButton, before:=1)
    .Caption = "Add Keyword ..."
    .Tag = "My_Cell_Control_Tag2"
    .OnAction = "'" & ThisWorkbook.Name & "'!" & "ShowDialog"
End With
    
End Sub