+ Reply to Thread
Results 1 to 2 of 2

Menu Help - cell reference

  1. #1
    Dan
    Guest

    Menu Help - cell reference

    Have a large workbook and placing a menu to manuever around. I want to base
    the menu list off a cell range. Names may change. I cant figure this out

    Dim myMnu As Object

    Set myMnu = CommandBars("Worksheet menu bar").Controls. _
    Add(Type:=msoControlPopup, before:=2)

    With myMnu
    .caption = "&Volunteers"
    .Controls.Add(Type:=msoControlButton, before:=1).caption =
    Sheet1.Range("m21")
    ..Controls(Sheet1.Range("m21")).OnAction = "Vol1" (blows out here)
    End with

    The values match. I have created menus for successfully with the same code
    with the exception of using the range ie caption ="text" ....
    ..controls("text).OnAction etc
    Where am I going wrong. MUCH thanks in advance

  2. #2
    JE McGimpsey
    Guest

    Re: Menu Help - cell reference

    This worked for me:

    .Controls(Sheet1.Range("m21").Text).OnAction = "Vol1"

    Unless you need the object variables, though, my preference would be to
    use something like this:

    With CommandBars("Worksheet menu bar").Controls.Add( _
    Type:=msoControlPopup, before:=2)
    .Caption = "&Volunteers"
    With .Controls.Add(Type:=msoControlButton, before:=1)
    .Caption = Sheet1.Range("m21").Text
    .OnAction = "Vol1"
    End With
    End With



    In article <[email protected]>,
    Dan <[email protected]> wrote:

    > Have a large workbook and placing a menu to manuever around. I want to base
    > the menu list off a cell range. Names may change. I cant figure this out
    >
    > Dim myMnu As Object
    >
    > Set myMnu = CommandBars("Worksheet menu bar").Controls. _
    > Add(Type:=msoControlPopup, before:=2)
    >
    > With myMnu
    > .caption = "&Volunteers"
    > .Controls.Add(Type:=msoControlButton, before:=1).caption =
    > Sheet1.Range("m21")
    > .Controls(Sheet1.Range("m21")).OnAction = "Vol1" (blows out here)
    > End with
    >
    > The values match. I have created menus for successfully with the same code
    > with the exception of using the range ie caption ="text" ....
    > .controls("text).OnAction etc
    > Where am I going wrong. MUCH thanks in advance


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1