Results 1 to 9 of 9

Change combobox list based on option button

Threaded View

zbor Change combobox list based on... 02-21-2012, 04:36 AM
MaczaQ Re: Change combobox list... 02-21-2012, 05:16 AM
zbor Re: Change combobox list... 02-21-2012, 06:26 AM
MaczaQ Re: Change combobox list... 02-21-2012, 06:49 AM
zbor Re: Change combobox list... 02-21-2012, 07:28 AM
MaczaQ Re: Change combobox list... 02-21-2012, 07:30 AM
zbor Re: Change combobox list... 02-21-2012, 07:34 AM
zbor Re: Change combobox list... 02-21-2012, 10:37 AM
zbor Re: Change combobox list... 02-24-2012, 04:31 AM
  1. #1
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,072

    Change combobox list based on option button

    I have two buttons:

    Private Sub Optionbutton1_Change()
    Call UserForm_Initialize
    End Sub
    
    Private Sub Optionbutton2_Change()
    Call UserForm_Initialize
    End Sub
    And code below:

    Private Sub UserForm_Initialize()
    Dim cPart As Range
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Set ws1 = Worksheets("Sheet1")
    Set ws2 = Worksheets("Sheet2")
    Dim optbut As Integer
    
    If Optionbutton2 Then 
    
            For Each cPart In ws1.Range("List1")
          With Me.CmbSiteName
            .AddItem cPart.Value
            .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
          End With
        Next cPart
    
    
    ElseIf Optionbutton1 Then
    
        For Each cPart In ws2.Range("List2")
          With Me.CmbSiteName
            .AddItem cPart.Value
            .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
          End With
        Next cPart
        
    End If
    
    Me.CmbSiteName.SetFocus
    End Sub
    By default:
    Optionbutton1=False
    Optionbutton2=True

    and 3 steps:

    When I run User form - it's OK (looking at List 1)
    When I click Optionbutton1 - it's OK (looking at list 2)
    When I now click back to Optionbutton2 it remains at List 2.. Why doesn't switch to List1?
    Last edited by zbor; 05-09-2012 at 09:50 AM.
    Never use Merged Cells in Excel

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