+ Reply to Thread
Results 1 to 11 of 11

Limiting custom menu selection based on sheet name

  1. #1
    Registered User
    Join Date
    12-05-2007
    Posts
    11

    Limiting custom menu selection based on sheet name

    hello

    i am considering the use of custom menus in an Excel application. is it possible to limit the selection of menu items for each worksheet? for example, sheet 1 all menu items are available, sheet 2 all but 2 menu items are available, sheet 3 all but 5 items are available.

    thanks in advance

  2. #2
    Registered User
    Join Date
    06-12-2008
    Location
    Newbury
    MS-Off Ver
    Office 365 ProPlus
    Posts
    92
    Not done it myself but it sounds perfectly possible.

    You would probably want to use the Workbook SheetChange event and use a few if's or select case statement to decide which customised menu to use.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You would need to run your create menu code each time a sheet is activated, within this code you would have a Select case or similar to decide which tools to allow subject to the activesheet name.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    12-05-2007
    Posts
    11
    thanks chergh and royUk.

    i was hoping to use the code created by Ron de Bruin http://www.rondebruin.nl/compatiblemenu.htm

    if i introduce the following code from the Microsoft support pages into the loop, it should achieve my desired outcome? that is, if worksheet doesn't equal something, don't display...

    Please Login or Register  to view this content.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I'm not sure what you are doing, are you working with Excel 2007? If you are then menus & commandbars don't work, you need to program the Ribbon.

  6. #6
    Registered User
    Join Date
    12-05-2007
    Posts
    11
    i'm working with Excel 2003.

    i'm using Example 1 as contained on Ron's page - using a worksheet that contains the menu elements used to create MyMenu in an Excel file.

    yet my workbook has many sheets and i do not want each option to be available on every worksheet. continuing with Ron's example, i want "Wizard" to be available from "My Menu" on sheet1 and sheet2, but not available on sheet3 (if you download the Menu_97-2007 file you'll need to insert two more sheets)

    i hope this helps you understand what i'm trying to achieve and how

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Use this amended code

    Please Login or Register  to view this content.
    And trigger it from the SheetActivate event

    Please Login or Register  to view this content.
    See the attached modified example
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    12-05-2007
    Posts
    11
    thanks royUK - that's great!

    you're adjusting the range depending on the sheet name to create differnt custom menus, where i was trying to have one custom menu yet make items active or inactive - yours is a lot simpler; amazing what a pair of fresh eyes and additional talent can do!

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Always keep it simple!

  10. #10
    Registered User
    Join Date
    12-05-2007
    Posts
    11
    too true.

    having said that, i've found part of the puzzle - the "enable" syntax and where it needs to be incorporated into the routine. now to figure out how to apply it to a range of sheet names, maybe using LIKE and the sheet name, or referring to a separate range of sheets?

    http://www.erlandsendata.no/english/...nvbacbmenuxl97

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by RobertY
    too true.

    having said that, i've found part of the puzzle - the "enable" syntax and where it needs to be incorporated into the routine. now to figure out how to apply it to a range of sheet names, maybe using LIKE and the sheet name, or referring to a separate range of sheets?

    http://www.erlandsendata.no/english/...nvbacbmenuxl97

    The select case that I added allows you to specify which sheets have the full menu

+ 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