Quick and simple question on ListBox control

xrb08162

New Member
Joined
Jul 19, 2010
Messages
8
Hi,

This should be simple but my lack of experience is hindering me.

I wish to add a list box control to a spreadsheet with two option in the drop down list. When one option from the drop down list is selected, I want it to enter a certain number into a cell, but when the other option is selected, a different number is entered into the same cell.

For example, if the two options are "Green" and "Blue", if Green is selected the value in cell C3 will be 5, but if Blue is selected, the value in C3 will be changed to 10.

I can do this with option buttons but I'd rather have a drop down list.

Many thanks
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,343
is it a listbox or a combobox?
Code:
sub listbox_AfterUpdate ()
if listbox.value="Green" then
range("C3").value = 5
else
range("C3").value = 10
End if
End Sub
the more simple way is to link the box to a cell (Properties->LinkedCell-> C4 for example)
so when you change the listbox it will change the cell C4
then put the formula in C3
=if (C4="Green", 5, 10)
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,939
Messages
5,508,243
Members
408,670
Latest member
lhmwnrexcel

This Week's Hot Topics

Top