+ Reply to Thread
Results 1 to 19 of 19

Active Sheet from Combo Box Selection (User Form)

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Active Sheet from Combo Box Selection (User Form)

    Hello all, and thank you for this wonderful resource.

    I have attached a sample document. I would like to be able to select a sheet name from the combo box on Sheet1 and automatically be transferred to the sheet I selected. I have found a VBA script that works if I am using the ActiveX combo box; however, I am having trouble creating a dynamic range using the ActiveX option (the workbook needs to be closed and re-opened for the combo box list to update).

    Any thoughts?

    Thank you in advance!
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    How/when are you populating the combobox?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Quote Originally Posted by Norie View Post
    How/when are you populating the combobox?
    The list in the combo box is populated using a named range. The range is determined dynamically. I am using the following formula to determine the range:

    =OFFSET(Sheet1!$A$1,1,0,COUNTA(Sheet1!$A:$A)-1,1)

    The combo box selection is made by the user. The combo box is essentially serving as a navigation feature. I will include the combo box on each sheet in the workbook.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Active Sheet from Combo Box Selection (User Form)

    this works with an active x combo box
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  5. #5
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Quote Originally Posted by Sean Thomas View Post
    this works with an active x combo box
    Thank you for this. I would really like to be able to use a user form, as opposed to ActiveX, if possible.

    Any thoughts?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Instead of a named range why not populate the combobox using AddItem.
    Please Login or Register  to view this content.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Or if you are using a userform.
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Active Sheet from Combo Box Selection (User Form)

    just run the macro showuserform
    then select which sheet and it will take you to that sheet

  9. #9
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Quote Originally Posted by Norie View Post
    Or if you are using a userform.
    Please Login or Register  to view this content.
    Thank you for taking the time to reply to my question, as well as providing a solution for both the ActiveX and User Form scenarios.

    I tried pasting the User Form code into the Sample.xlsm workbook to no avail, likely due to my lack of experience with VBA scripts.

    Would it be too much to ask for you to add the code to the Sample workbook that I uploaded? All of your help is greatly appreciated!

    Kindest regards,
    Justin

  10. #10
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Quote Originally Posted by Sean Thomas View Post
    just run the macro showuserform
    then select which sheet and it will take you to that sheet
    Thank you for your reply! I appreciate you providing a sample workbook.

    I tried your solution, which did work. I ran the macro, a popup window appeared, I selected the sheet I wanted to view and I was taken to the sheet.

    Is there any way to modify your code so that I can select the sheet I would like to view form the combo box (user form), instead of the popup window solution?

    Thank you again for all of your kind support.

    Best regards,
    Justin

  11. #11
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Active Sheet from Combo Box Selection (User Form)

    That was a userform that opened, after you select a sheet, it activates the sheet then closes the userform.
    what exactly are you trying to achieve?

  12. #12
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Quote Originally Posted by Sean Thomas View Post
    That was a userform that opened, after you select a sheet, it activates the sheet then closes the userform.
    what exactly are you trying to achieve?
    I apologize for not being clear.

    I want the user of the worksheet to be able to click the drop down arrow of the combo box (user form), click on a sheet name (which is populated using the dynamic range formula) and for the respective sheet name to be activated. I.E.: A user clicks the arrow, selects "Sheet2" and is taken to "Sheet2".

  13. #13
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Active Sheet from Combo Box Selection (User Form)

    That's more complicated than my version. Why do you want a dynamic range formula for the rowscource? surely selecting the sheet in a list box is doing the same as a combobox?
    any reason why you want to make it more complicated?

  14. #14
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Quote Originally Posted by Sean Thomas View Post
    That's more complicated than my version. Why do you want a dynamic range formula for the rowscource? surely selecting the sheet in a list box is doing the same as a combobox?
    any reason why you want to make it more complicated?
    I interpret your response as two questions:

    1.) Why do you want the range of sheet names to be dynamic?
    2.) Why do you want a combo box as opposed to pop-up window?

    Responses:

    1.) I am going to make heavy use of indirect references to sheet names so that I can easily "exchange" sheets as I further develop the sheets. If a new sheet has a new name, I want to be able to change a "directory" of sheet names. By using a dynamic column, or range, of sheet names, I am hoping to make this process as efficient as possible.
    2.) Simply clicking a drop-down box of sheet names seems much easier (and more familiar, as it mimics a choosing a recently visited web address in a web browser), than having a pop-up window pop-up and then selecting a sheet and double clicking it (or pressing "Ok").

    I don't mean to be burdensome, I am simply searching for the most elegant approach because I want those using the Workbook to make the most of it.

    Thank you again, I truly appreciate all of your time!

    Kindest regards,
    Justin

  15. #15
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    There is no way I could have stumped you with this! Your help is greatly appreciated.

  16. #16
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Active Sheet from Combo Box Selection (User Form)

    Here you go hopefully this is what you want.
    When you activate the worksheet it will load the combobox with anything in A2:A lastrow.

  17. #17
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Quote Originally Posted by Sean Thomas View Post
    Here you go hopefully this is what you want.
    When you activate the worksheet it will load the combobox with anything in A2:A lastrow.
    Sean,

    Thank you for taking the time to reply again! I appreciate you uploading the sample workbook as well.

    Did you add the code to the combo box or the ActiveX box?

    When attempting to make a selection on the combo box, I received the following error: "Cannot run the macro “From Web.xlsm’!DropDown1_Change’. The macro may not be available in this workbook or all macros may be disabled."

    The ActiveX box is not populated.

    Thank you again for taking the time to respond, I really do appreciate your time.

  18. #18
    Registered User
    Join Date
    09-05-2011
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Active Sheet from Combo Box Selection (User Form)

    Thank you for taking the time to reply as well!

    I have added the code you provided to the worksheet. When attempting to make a selection, I receive the following error: "Cannot run the macro “From Web.xlsm’!DropDown1_Change’. The macro may not be available in this workbook or all macros may be disabled."

    Any thoughts?

    Quote Originally Posted by Norie View Post
    Or if you are using a userform.
    Please Login or Register  to view this content.

  19. #19
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Active Sheet from Combo Box Selection (User Form)

    Hi 1st reply,
    I added the code to the active x combobox.
    If you select a different sheet first and then go back to sheet 1 the list will be compiled as it uses the worksheet activate event to add the data.
    2nd reply
    you are using Userform events on a worksheet, that wont work.

    I have added another file.
    This has one active x combobox
    I have created a dynamic named range called SheetNames, this will increase with size as you add more sheet names
    I have set the ListFill range (in the properties of the combobox) to Sheetnames. This will solve the problem of the list not always being filled.
    therefore you only need one event in the sheet module
    Please Login or Register  to view this content.
    this should be more like what you need

+ 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. [SOLVED] Form Control Combo Box Selection
    By wacky_diva in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2013, 08:31 PM
  2. [SOLVED] How can I active a row from a listbox in a user form?
    By Magma310 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-07-2013, 03:42 PM
  3. combo box user form code for two combo boxes
    By robert.begley1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2012, 02:25 PM
  4. help with user form and combo box
    By TechRetard in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-01-2011, 04:56 AM
  5. [SOLVED] combo box in a user form
    By juliejg1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2006, 04:20 PM

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