+ Reply to Thread
Results 1 to 8 of 8

Show UserForm from ComboBox

Hybrid View

sgp Show UserForm from ComboBox 11-15-2011, 04:30 PM
snb Re: Show UserForm from... 11-15-2011, 04:58 PM
sgp Re: Show UserForm from... 11-17-2011, 07:28 AM
john55 Re: Show UserForm from... 11-17-2011, 07:58 AM
sgp Re: Show UserForm from... 11-17-2011, 08:03 AM
snb Re: Show UserForm from... 11-17-2011, 08:08 AM
john55 Re: Show UserForm from... 11-17-2011, 08:09 AM
sgp Re: Show UserForm from... 11-17-2011, 08:48 AM
  1. #1
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Question Show UserForm from ComboBox

    Hi

    I have many userfoms and I was wondering whether I could select a userform from a combobox in a worksheet. I have tried to play around with codes but can't seem to get this to work.

    Regards.
    Last edited by sgp; 11-17-2011 at 08:48 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Show UserForm from ComboBox

    cfr the attachment
    Attached Files Attached Files



  3. #3
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Show UserForm from ComboBox

    Hmm doesn't seem to work for me..

    I have copied this code in the worksheet:

    Private Sub ComboBox1_Change()
    Select Case ComboBox1.ListIndex
        Case 0
          UserForm1.Show
        Case 1
          UserFormSecurity.Show
        End Select
    End Sub

    and this in the workbook:

    Private Sub Workbook_Open()
        For Each cp In ThisWorkbook.VBProject.VBComponents
            If cp.Type = 3 Then c01 = c01 & "|" & cp.Name
        Next
        Sheets(5).ComboBox1.List = Split(Mid(c01, 2), "|")
    End Sub

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Show UserForm from ComboBox

    hi sgp,
    it works for me, try to save and open it again.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  5. #5
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Show UserForm from ComboBox

    Hi john55,

    I'm getting an error on this line:
    [code]
    Sheets(5).ComboBox1.List = Split(Mid(c01, 2), "|")
    [code]

    Would I need to enter the sheet number or name?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Show UserForm from ComboBox

    Use the sheet's name.

    Have you got a combobox in the sheet ?

  7. #7
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Show UserForm from ComboBox

    I do not know how yr workbook looks like, for example I added a new ComboBox in Sheet1 and ammended the code for that ComboBox and added
    '
    '
     Sheets("Sheet1").ComboBox1.List = Split(Mid(c01, 2), "|")
    '
    snb, I'm sorry, hope you do not mind...
    Last edited by john55; 11-17-2011 at 08:12 AM.

  8. #8
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Show UserForm from ComboBox

    Thanks snb and john55,

    Finally works great! What I wasn't doing was saving the worksheet as macro-enabled!!

    Thanks!!

+ 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