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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,394
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
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)
 

Watch MrExcel Video

Forum statistics

Threads
1,133,324
Messages
5,658,155
Members
418,430
Latest member
Kizega

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
Top