Consulting

Results 1 to 2 of 2

Thread: toggle right click

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    toggle right click

    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
    [VBA]
    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

    [/VBA]
    thanks
    moshe

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]
    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
    [/vba]

    Put this in the appropriate worksheet code module.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •