Putting a list into a ComboBox in a UserForm1

bugatti79

Board Regular
Joined
Feb 18, 2012
Messages
70
Folks,

I am trying to put a a list of names into a ComboBox that is inserted in a user form. I have used the record macro feature to capture the code. Here is the snippet that I put into the ComboBox procedure

Code:
Private Sub ComboBox1_Change()    

With Selection
        .ListFillRange = "'Table of Material Data'!$A$3:$A$19"
        .LinkedCell = ""
        .DropDownLines = 8
        .Display3DShading = False
    End With
End Sub

When I run it, the dialogue box comes up with the ComboBox but it is empty. How do I put a list into it?

Ultimately, say I have 2 materials each with 2 different mechanical properties. I want to perform some calcs when a material is selected.
Any help will be appreciated.
Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Put that code in the userform's Initalize event rather than the Combobox's Change event.

Hi

I have done as you have requested but I get an error about 'object does not support this property or method.

Code:
Private Sub UserForm_Initialize()    
With Selection
        .ListFillRange = "'Table of Material Data'!$A$3:$A$19"
        .LinkedCell = ""
        .DropDownLines = 8
        .Display3DShading = False
    End With
End Sub

THe above code has no connection with the ComboBox. What code goes into this ComboBox?

thanks
 
Upvote 0
The following:

Code:
Private Sub UserForm_Initialize()

With Me.ComboBox1
        .RowSource = "'Table of Material Data'!$A$3:$A$19"
    End With
End Sub

should populate the combobox on the form.

Best regards
Richard
 
Upvote 0
The following:

Code:
Private Sub UserForm_Initialize()

With Me.ComboBox1
        .RowSource = "'Table of Material Data'!$A$3:$A$19"
    End With
End Sub

should populate the combobox on the form.

Best regards
Richard

Thanks, that works.

I have another query.
Each material in the drop down menu has associated material properties. So when material is selected how do I assign the associated material properties to a row of cells for further calculation.

I know this excel line works but I don't know its equivalent in VB

=INDEX('Table of Material Data'!A3:I19,MATCH(B6,'Table of Material Data'!A3:A19,0),3)

Thanks
 
Upvote 0
Thanks, that works.

I have another query.
Each material in the drop down menu has associated material properties. So when material is selected how do I assign the associated material properties to a row of cells for further calculation.

I know this excel line works but I don't know its equivalent in VB

=INDEX('Table of Material Data'!A3:I19,MATCH(B6,'Table of Material Data'!A3:A19,0),3)

Thanks

Private message me for an email address, I think it would be easiest to see the file.

Best regards
Richard
 
Upvote 0

Forum statistics

Threads
1,203,468
Messages
6,055,595
Members
444,800
Latest member
KarenTheManager

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top