PDA

View Full Version : toggle right click



lior03
01-23-2006, 06:51 AM
hello
how do i make the right click menu visible .
i want to add an item to the cell shortcut only when the cell or selection i choose contain formula and if not then make it invisible.just like the comment items that apear only if there is a comment.
what about

Sub createcomment()
Dim cell As Range
For Each cell In selection
If cell.HasFormula Then
Dim NewItem As CommandBarControl
Set NewItem = CommandBars("Cell").Controls.Add
NewItem.Caption = "turn formula red"
NewItem.OnAction = "marco"
NewItem.BeginGroup = True
NewItem.FaceId = 393
Else
End If
Exit Sub
Next
End Sub


thanks

Bob Phillips
01-23-2006, 08:17 AM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ws_exit
Application.EnableEvents = False
Application.CommandBars("Cell").Controls("turn formula red").Visible = Target.Value <> ""

ws_exit:
Application.EnableEvents = True
End Sub


Put this in the appropriate worksheet code module.