Update numerous comboxes at once
Yes my comboboxes are on a user form - sorry i forgot to state that.
I tried to post a simplified version of my code to make my explanation
easier, however here is the full version;
Sub updateranges()
Dim rng
Dim cmbo As ComboBox
j = 4
i = 70
rng = Sheets("sheet4").Range("d" & j).Value
For j = 4 To 34
cmbo = Me.Controls("Combobox" & i)
If rng = "Pet1" Then cmbo.RowSource = "details!c4:c24"
If rng = "Pet2" Then cmbo.RowSource = "details!e4:e24"
If rng = "Pet3" Then cmbo.RowSource = "details!g4:g24"
If rng = "Pet4" Then cmbo.RowSource = "details!i4:i24"
If rng = "Pet5" Then cmbo.RowSource = "details!k4:k24"
If rng = "Pet6" Then cmbo.RowSource = "details!m4:m24"
If rng = "Unplanned" Then cmbo.Value = "N/A"
j = j + 1
Next i
Essentially I need to;
Check a varable range and update a related combobox
So if rng = Sheets("sheet4").Range("d4").Value and d4 value = "Pet4"
then the rowsource of ComboBox70 would be "details!i4:i24" (as i would
= 70 and j would equal 4 and cmbo would equal ComboBox70)
The above code still errors in the same place as before. Thanks,
|