Setting Rowsource property using VBA

respinosa

New Member
Joined
Dec 14, 2016
Messages
5
I've been trying to set the Rowsource property for a combo box using this code:

Private Sub Sales_Width_Tolerance_Click()
Me.Sales_Width_Tolerance.RowSourceType = "Value List"
Me.Sales_Width_Tolerance.RowSource = "+/- 1 mm"
End Sub

It will not work. Is there something that needs to be selected in the VBA environment under Tools>>>References...?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
It's basically working for me but I cannot understand why you would do this. You want to change the rowsource when the combobox is clicked? Plus you won't see anything change visibly even if it works.

It seems that the event fires when the user makes a combobox selection, not just any old click. Not sure though - would need some tests (or check some documentation on the event).

Note: you do not need anything special checked in references for this.
 
Last edited:
Upvote 0
I was testing the code to see if it would work before I invested a WHOLE lot of time writing what I really wanted to do. I would actually have several more choices in the list based on a value that the end user selects in another combo box. Should I use a different event in this combo box? I used the Got Focus event and it didn't work either. Alternatively, should I use the After Update event of the other combo box to update the row source of this combo box? Thanks!
 
Upvote 0
Yes, the after update event of the other combobox may work better, I think.
 
Upvote 0
Well, I tried the After Update event of the other combo box and it still doesn't work. Do you know of any other resources I can check?
 
Upvote 0

Forum statistics

Threads
1,221,777
Messages
6,161,871
Members
451,727
Latest member
tyedye4

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