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
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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)
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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