jasonb75
Well-known Member
- Joined
- Dec 30, 2008
- Messages
- 15,517
- Office Version
- 365
- Platform
- Windows
Hi all.
I've just tried populating a set of comboboxes in a form using the code below and I'm getting the message, Runtime Error 381 Could not set the List property. Invalid property array index.
A1:G1 contain the names of the comboboxes, the idea is to populate each of the boxes named in that range with a list found below it. This was just a quick attempt before packing up for the day so it's likely riddled with errors and bad ideas. I'm almost certain that
Any suggestions for a fix, or ways to improve would be appreciated.
Thanks in advance, Jason.
I've just tried populating a set of comboboxes in a form using the code below and I'm getting the message, Runtime Error 381 Could not set the List property. Invalid property array index.
A1:G1 contain the names of the comboboxes, the idea is to populate each of the boxes named in that range with a list found below it. This was just a quick attempt before packing up for the day so it's likely riddled with errors and bad ideas. I'm almost certain that
Me.Controls(c.Value).List
is wrong, I just don't seem to be able to find the correct way to express that part.
Code:
Private Sub UserForm_Initialize()
Dim rng As Range, c As Range, lRow As Long
With Lists
Set rng = .Range("A1:G1")
For Each c In rng
lRow = .Cells(.Rows.Count, c.Column).End(xlUp).Row
Me.Controls(c.Value).List = c.Offset(1).Resize(lRow - 1)
Next c
End With
Me.Show
End Sub
Any suggestions for a fix, or ways to improve would be appreciated.
Thanks in advance, Jason.