Siple Question I think????????

bfraser

Board Regular
Joined
Apr 15, 2006
Messages
113
I can create a list box no problem, but how do I code a cell to list 2 options but only populate the cell with one of the options when selected?

Example:
When I select cell G3 I need a drop down list to appear that shows both an abbreviation and a name, such as

SK Saskatchewan
AB Alberta
BC British Columbia

But when I choose the AB Alberta option, I only want the cell to be populated with the abbreviation AB

How would I go about doing this? What would I have to type in cell G3?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
  • Put your drop down list in G3
  • Right-click on the sheet tab and select View Code in the pop up menu
  • Paste the code below in the VBA edit window.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address = "$G$3" Then
        Application.EnableEvents = False
            Target.Value = Left(Target.Value, 2)
        Application.EnableEvents = True
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,682
Members
452,937
Latest member
Bhg1984

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