Excel VBA-Populate one combobox with anoter combobox results

N

Nico Le Roux

Good day

I am new in this VB world and need some help. (Please explain it in baby
language)

I have the following information

Plant PlantDesc StorageLoc StorageLocDescription
100 Plant 1 1001 ExhaustPlant
100 Plant 1 1002 Seats
100 Plant 1 1003 Fabriction
200 Plant 2 2001 Engine
200 Plant 2 2002 Chassis
300 Plant 3 3001 Pressing


I have created name ranges on separate sheet
Name Range "PLANT" Plant PlantDescription
100 Plant 1
200 Plant 2
300 Plant 3
Name Range "Sloc100" StorageLocation StorageLocDescription
1001 ExhaustPlant
1002 Seats
1003 Fabriction
Name Range "Sloc200" StorageLocation StorageLocDescription
2001 Engine
2002 Chassis
Name Range "Sloc300" StorageLocation StorageLocDescription
3001 Pressing



On my user spreadsheet I have created two combo boxes. One for Plant and
populate it with the name PLANT.
The user choose the plant and the value appear in the spreadsheet cell.

What I would like to do is to populate the 2nd combo box (cbosloc) with the
specific plant as per the value on a specific row in the spreadsheet with
the storage locations within that plant.

My 1st step was to find out what the current row number and store the plant
number in a variable called Plant.

Public Sub MyAddress()
'get current row
MyRow = ActiveCell.Row
End Sub

The 2nd step was to populate the combo box with the storage locations from
the plant

Private Sub cbosloc_DropButtonClick()
Dim myRange
Dim plant
plant = Range("T" & MyRow).Value

Select Case plant
Case 100
myRange = sloc100
Case 200
myRange = sloc200
Case 300
myRange = sloc300
Case Else
myRange = sloc
End Select
cbosloc.ListFillRange = myRange
End Sub

Problem: My combo box don't populate with the results from my variable
myRange ???????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top