简体   繁体   中英

How to populate a cell by giving start letter

Lets assume, in excel, I have a cell which I want a data as Auto, Close, Trigger.

I want to populate it automatically if I type just the first char ie For Auto, just A and hit Enter, it should fill as Auto..

Right click on your worksheet name and select View Code . Paste this in and change A1 to whatever your specific cell is.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub

    If Target = Me.Range("A1") Then
        Select Case UCase(Target.Value)
            Case "A"
                Target.Value = "Auto"
            Case "C"
                Target.Value = "Close"
            Case "T"
                Target.Value = "Trigger"
        End Select
    End If
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM