gemcgraw
Board Regular
- Joined
- Mar 11, 2011
- Messages
- 72
I'm not sure if my issue is using Microsoft Office Excel Professional 2019 or something else. However, I have a combobox (ComboBoxVendors) on a userform that I need populated with vendor names. I'm trying to set the RowSource value in VBA code and getting, "Runtime error 308. Could not set the RowSource property. Invalid Row property value." Below is the code I have set on the Private Userform_Activate subroutine:
I'm using this sub to load the values in the ComboboxVendors on the UserForm ahead of time. There have been numerous suggestion on MrExcel and other forums that suggest several variations of this; however, I still get the same error. The only way around the error is to use this code:
UserForm1.ComboBoxVendors.RowSource = "Vendors!B2:B5"
This resolves the error and the ComboBoxVendors values load as expected. However, the range "B2:B5" will grow. Thus, I don't want to "hard-code" the range. And, I don't want to simply push the end of the range out to some crazy number and end up with a mile long of blanks.
What am I missing?
Code:
Dim Source As String
'Find the last populated row in the range.
NextRow = Sheets("Vendors").Range("B" & Rows.Count).End(xlUp).Row
'Assign the complex RowSource string into one stringed value
Source = "Vendor!B2:B" & NextRow
'Set the RowSource property.
UserForm1.ComboBoxVendors.RowSource = Source
I'm using this sub to load the values in the ComboboxVendors on the UserForm ahead of time. There have been numerous suggestion on MrExcel and other forums that suggest several variations of this; however, I still get the same error. The only way around the error is to use this code:
UserForm1.ComboBoxVendors.RowSource = "Vendors!B2:B5"
This resolves the error and the ComboBoxVendors values load as expected. However, the range "B2:B5" will grow. Thus, I don't want to "hard-code" the range. And, I don't want to simply push the end of the range out to some crazy number and end up with a mile long of blanks.
What am I missing?