![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 2
|
Is it possible to map keys to Text? Lets say I was in cell A1 and I wanted to be able to key in 1 and the word "Dental" would appear. Any suggestions would be greatly appreciated. Thanks
|
|
|
|
|
|
#2 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Sure, very easy really. This code must be placed in the Private Module of the Sheet Object. To do this. right click on the sheet name tab nad select "View Code".
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" Then If IsNumeric(Target) Then Target = Choose(Target, "Dental", "Doctor", "Vet", "Surgeon") End If End If End Sub This one is geared for numeric entries only in cell A1. If you type 1, then Enter you get "Dental" if 2 "Doctor" etc. If however you want text as well use the Select case. Option Explicit Option Compare Text Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" Then Select Case Target.Value Case 1 Target = "Dental" Case 2 To 5 Target = "Doctor" Case Is > 10 Target = "Fred" Case "Octopus" Target = "Squid" End Select End If End Sub Remove the "Option Compare Text" Statement for case sensitivity. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Posts: 2
|
Thanks Dave!
It worked wonderfully! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|