Format Cells to Keystroke
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Format Cells to Keystroke

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #3
    New Member
    Join Date
    Mar 2002
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks Dave!

    It worked wonderfully!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com