0

I just started to use VBA into excel and I'm trying to create a User Form where I select data from the active sheet (the Userform shall be duplicated once I duplicate the sheet where it is included and all the reference shall be to te active sheet):

  • the Userform is named "SystemDesignUserForm"

  • the actual sheet where it is included is named "System Design"

  • the ComboBox is named "DIAComboBox" and shall list the data included into cells "w6:w33".

I tried with the code:

DIAComboBox.List = Range("W6:W33").Value

and also with

DIAComboBox.List = ActiveSheet.Range("W6:W33").Value

and with:

DIAComboBox.List = Worksheets("System Design").Range("W6:W33").Value

but it doesn't wotk: the combobox appear void.

Do you have any suggestion?

1 Answers1

0

You can try iterating through the range and populate:

'set worksheet
Dim ws as Worksheet
Set ws = Worksheets("System Design")

'loop through and collect range
    For each c in ws.Range("W6:W33")
        With Me.DIAComboBox
            .AddItem c.Value
        End With
    Next c

    Me.DIAComboBox.SetFocus

Hopefully this helps.

MrOtter
  • 1
  • 3