+ Reply to Thread
Results 1 to 13 of 13

Using a list box or other control form to activate different macros

  1. #1
    Registered User
    Join Date
    11-26-2003
    Location
    Scotland
    Posts
    26

    Using a list box or other control form to activate different macros

    Hi,

    I am designing (badly!) an excel file that is intended to be as user friendly as possible. I would like to add in a navigation feature using a list box or other appropriate control form that will take the user to the correct tab in the workbook depending on which item they choose from the list.

    My aim is too hide all the tabs at the bottom whilst not crowding my page with multiple command buttons, and still be able to navigate easily through the workbook.

    Any suggestions? Your help is greatly appreciated.

    Thanks & best regards,

    Stuart (Melvin)
    melv

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    One way of many.

    Create a named range that contains the sheet names to include in the list. Call this range SHEETNAMES.

    Add a combobox from the Forms toolbar to the sheet.
    Set the Input Name of the control to SHEETNAME
    Assign the following macro to that control.

    Code in standard code module.
    Please Login or Register  to view this content.
    You can now copy that control to any other sheet(s)
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    11-26-2003
    Location
    Scotland
    Posts
    26
    Thanks Andy!

    Excuse my naivity, but I can't find the "Input Name" field anywhere!?? It doesn't appear to be on the Properties or the Format Control field. I have a ListFillRange and ListRows option but that seems to be it. I have Excel 2003 if that helps.

    Thanks for any further input you can provide. Your help means a lot.

    Stuart.

  4. #4
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi melvin,

    I've attached a sample workbook with Andy's instructions so you can have a look at how it works
    Attached Files Attached Files
    Hope this helps

    Seamus

  5. #5
    Registered User
    Join Date
    11-26-2003
    Location
    Scotland
    Posts
    26
    Sorry to trouble you again Andy,

    I put in "SHEETNAMES" into the ListFillRange field and the combo box seemed to pick them up.. unfortunately when I ran the code there was a runtime error with the following message;

    Run-time error '13':

    Type mismatch

    It seemed to bug at the line, "With ActiveSheet.Shapes(Application.Caller)"

    Thanks for your support.

    Stuart.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Thanks SOS.

    melvin, sounds like you used the ActiveX control rather than the forms.

  7. #7
    Registered User
    Join Date
    11-26-2003
    Location
    Scotland
    Posts
    26
    Sorry Andy,

    Hate to be a nuisance but still having problems.. any idea how I can debug the code to give me the result I'm looking for?

    Sorry, meant to state that I need more help in the last post.

    Regards,

    melvin

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    If you are using a activex control then you can add code to the change event

    Please Login or Register  to view this content.
    You will need the code in the event of each combo box.

  9. #9
    Registered User
    Join Date
    11-26-2003
    Location
    Scotland
    Posts
    26
    Thanks chaps,

    Both methods work a treat! A great help to me.

    All the best.

    melvin

  10. #10
    Registered User
    Join Date
    11-26-2003
    Location
    Scotland
    Posts
    26
    Actually, while we're on this subject, I'm looking to have a similar function with a Combo Box Form or Active X Combo Box control whereby the user picks from a list of words and depending on which word he/she picks, the active cell is color coded accordingly. I assume the tool would be the same, but not sure how the code would look? Any suggestions?

    I realise I may be pushing my luck here!

    Once again, tremendous help so far, any further advice would be a bonus.

    melvin

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Which control type, ActiveX or Forms, did you end up using?

    If the choice of colours is limited conditional formatting maybe sufficient.

  12. #12
    Registered User
    Join Date
    11-26-2003
    Location
    Scotland
    Posts
    26
    I ended up trying both, however both have a minor problem I'm trying to work out... when I select say, "sheet 1" from sheet 3's combo box, then I go from sheet 1 back to sheet 3 and try to select "sheet 1" again, "sheet 1" is already showing in the pick list, therefore when I try to select it, the form / Active X control doesn't recognise a change and therefore doesn't switch over to sheet 1. Is there anyway I can default / reset all of them to a 'blank' so that I will always be selecting a different value from the one shown?

    Alternatively, can you think of a better control type to use for navigation?

    Extremely grateful for the help.

    melvin

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    For dropdown you can use
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How do I use VBA to choose the source cells for a list with Data Validation?
    By baconcow in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-11-2008, 05:36 PM
  2. Populate an Excel Form from a table on push button click
    By munzer1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-23-2007, 09:55 PM
  3. List - Multiple List Interaction
    By JennyW in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-02-2006, 11:12 AM
  4. Populating a list box or combo box on a User Form
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2006, 08:28 AM
  5. Mouse clicks and list control
    By aaronwkelley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2006, 05:53 AM

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