Reputation: 3
Code has been working perfectly for past year. Made some edits and extended some of the data - ensured it was all lined up correct at the time. I came to use it but now I am getting the following error
runtime error 380: could not set the rowsource property"
I have narrowed it down to .RowSource = "VOLNAME2"
but I haven't changed anything about this data.
The error initially comes up when you press the button to bring this UserForm up, so debug starts on newlog.show
(separate module). However, I used F8 to highlight the error line as above.
I tried redefining the name manager and renaming it. Deleted and re-entered it. I had a look at some other answers but couldn't see anything that stood out as the answer.
Sub UserForm_Initialize()
Dim R As Range
Me.TextBox2.Locked = True
Me.TextBox3.Locked = True
Me.CommandButton1.Enabled = False
With Me.ComboBox4
.RowSource = "VOLNAME2"
.MatchEntry = fmMatchEntryComplete
.Style = fmStyleDropDownList
End With
With Me.ComboBox1
.RowSource = ""
.MatchEntry = fmMatchEntryComplete
.Style = fmStyleDropDownList
For Each R In Range("'Database'!F4:F23")
.AddItem R.Text
Next
End With
With Me.ComboBox3
.RowSource = ""
.MatchEntry = fmMatchEntryComplete
.Style = fmStyleDropDownList
For Each R In Range("'Database'!F26:F51")
.AddItem R.Text
Next
End With
With Me.ComboBox2
.RowSource = ""
.MatchEntry = fmMatchEntryComplete
.Style = fmStyleDropDownList
For Each R In Range("'Database'!H3:H32")
.AddItem R.Text
Next
End With
End Sub
I am expecting the defined name "volname2" to populate combobox 4
Upvotes: 0
Views: 1758
Reputation: 644
You can't update the rowSource for these to straight values, they require a range or some other lookup. Change:
With Me.ComboBox4
.RowSource = "VOLNAME2"
.MatchEntry = fmMatchEntryComplete
.Style = fmStyleDropDownList
End With
To one of these options:
Option - 1 Clears the list adds the requested text and sets the index to display that value
ComboBox1.Clear
ComboBox1.AddItem ("volname2")
ComboBox1.ListIndex = 0
Option 2 - Clears the list and sets the text value to requested value. Personally this is a bad choice, because you'll have to forcibly clear the text value with .Text = "" if you want to re-use it.
ComboBox1.Clear
ComboBox1.Text = "volname2"
Upvotes: 0