
Use a user-defined function to create your
own AutoText
The last tip in this chapter provides a way to use AutoText inside
your worksheet. This functionality can be useful for a number of
different Excel-based tasks.
4
To create your own AutoText:
1. Press <Alt+F11> to open the Visual Basic Editor.
2. From the Insert menu, click Module.
3. Type the following function:
Function AuTxt(rng As Range) As String
Select Case rng.Value
Case 1
AuTxt = "fire"
Case 2
AuTxt = "water"
Case 3
AuTxt = "heaven"
Case Else
AuTxt = "invalid text"
End Select
End Function
4. Return to the worksheet. Select cells B1:B4 or a much
larger range and type the formula =AuTxt(A1).
5. Press <Ctrl+Enter> ...