Help VBA to populate combo box using a range

tigersden

Board Regular
Joined
Oct 5, 2005
Messages
91
I am trying to populate a second combo box after the first has be changed.
The first combo box is linked to a cell on sheet2, the selected value on sheet2 is used in a vlookup to return a range of points that the chosen grade covers.
eg Grade 1 is chosen, the linked cell on the second sheets value is 1, the vlookup returns a range F5:F10 which is held in cell g20.
I have tried using VBA on change event but am unable to assign the range held in G20 as the combobox's list. This second combo box is only enabled after the first has changed.

I hope this makes some sense
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
What have you tried?
Code:
Combobox2.RowSource = Range("G20").Value
 
Upvote 0
Where is the combobox located?

The code I posted would be for one on a userform, ListFillRange would be the correct property for a combobox from the Control Toolbox.
 
Upvote 0
Hi Norie,
The combo box is on worksheet but it is from the controls toolbox.

The code worked once but since I jave added another select statement it is giving "An Undefined Error" on the line in bold.
Altogether there will be 6 select statements, & six sets of these combo boxes.


Sub DropDown22_Change()
Worksheets("Sheet1").cboPPoint1.Enabled = True
Select Case Worksheets("Sheet2").Range("B4").Value
Case Is = 1
Worksheets("Sheet1").cboPPoint1.Clear
cboPPoint1.RowSource = Range("I4").Value
Case Is = 2
Worksheets("Sheet1").cboPPoint1.Clear
cboPPoint1.RowSource = Range("I4").Value
End Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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