IF function and combobox

Solved
Skyner68 Posted messages 3 Status Member -  
Skyner68 Posted messages 3 Status Member -
Hello,

I created a small application for work in which I use comboboxes located in userforms that I configured for the data source like this:

private sub userform_initialize()
Combobox1.list = sheets ("param"). Range ("a2:a17").value
End sub


It works perfectly!

My question is
Can we, using the if function (or another), automatically modify the data range based on the value of a given cell?

Basically, if A1=house then we take for combobox1 the range A1:A12 and if it’s garage then we take the range B1:B12.

Thank you in advance.

1 answer

f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
 
Hello,

Well yes, it's all written in your second sentence.......
0
Skyner68 Posted messages 3 Status Member
 
I suspect, but how? ^^ I've tried several codes found online and they don't work :/
0
f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717 > Skyner68 Posted messages 3 Status Member
 
Re,
Ah yes, but the instructions are in English not in French......

Little joke

Private Sub userform_initialize() With Sheets("param") If .Range("A1") = "maison" Then Set plage = .Range("A2:A17") ElseIf .Range("A1") = "garage" Then Set plage = .Range("B2:B17") Else End If ComboBox1.List = plage.Value End With End Sub
0
Skyner68 Posted messages 3 Status Member > f894009 Posted messages 17417 Registration date   Status Member Last intervention  
 
Perfect, that's great, thank you for the quick response.
0