Drop Down Lists

snmark

New Member
Joined
May 14, 2007
Messages
25
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Dear sirs,
Drop down list of names , each name reflecting a number. So that when selecting a name it shows its number. For example, in calculating compound interest, the drop down list of names: Annually, Bi annually, Quarterly, Monthly, Weekly , Daily are reflected in the cell by the numbers 1, 2, 4, 12, 52, and 365 respectably.

Hope Ive explained it clearly enough.

Thanks with regards

Stephen
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi,

As long as you have your List as a reference ... nothing will prevent you from using a simple VLookup ... :wink:
 
Upvote 0
If I have understood correctly that you want the number to appear in the actual cell where the data validation is then that is possible as follows.

- Set up the Data Validation cell(s) with your 6 text choices. I have used cell E1.
- Use this Worksheet_Change code

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$E$1" Then
    Application.EnableEvents = False
    If Len(Target.Value) > 0 Then Target.Value = Split("1 2 4 12 52 365")(Application.Match(Target.Value, Array("Annually", "Bi annually", "Quarterly", "Monthly", "Weekly", "Daily"), 0) - 1)
    Application.EnableEvents = True
  End If
End Sub
 
Upvote 0
Another option, if you want the user to be able to see both the text and the number, but only end up with the number is to set up your DV with a list like I have in column L, use that list in your Data validation and use this Worksheet_Change code instead.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$M$1" Then
    Application.EnableEvents = False
    Target.Value = Mid(Target.Value, InStr(1, Target.Value, ":") + 1)
    Application.EnableEvents = True
  End If
End Sub

Excel Workbook
LM
1Annually:14
2Bi annually:2
3Quarterly:4
4Monthly:12
5Weekly:52
6Daily:365
DV Replace (2)
#VALUE!
 
Upvote 0
another VBA option for you

Data validation in cell
Allow : List
Source : 1 Annually,2 Bi Annually,4 Quarterly,12 Monthly,52 Weekly,365 Daily

so that the user sees these option in cell
1 Annually
2 Bi Annually
4 Quarterly
12 Monthly
52 Weekly
365 Daily

VBA
Place code in sheet module
RightClick on sheet tab \ select ViewCode \ paste code into VBA editor \ back to Excel with {ALT}{F11}
Save workbook as macro-enabled
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("A2"), Target) Is Nothing Then
        Application.EnableEvents = False
        Target = Val(Target)
        Application.EnableEvents = True
    End If
End Sub
 
Last edited:
Upvote 0
Thank you Peter and Yongle. I will try both and let you know if it’s successful.

Very grateful indeed.

Kind regards

Stephen
 
Upvote 0
Thank you Peter and Yongle. I will try both and let you know if it’s successful.

Very grateful indeed.

Kind regards

Stephen

I've tried both, no success with Peters, but success with Yongle's. Not say Peter, that anything was wrong with your suggestion, as its very likely that my application of it was suspect.

Thank you both for your prompt and professional response, very grateful indeed.

cheers, with regards

Stephen
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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