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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,434
  • 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
 

Forum statistics

Threads
1,143,637
Messages
5,719,966
Members
422,251
Latest member
bonebreaker100

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