select case to replace text with different text
On Sun, 10 Jan 2010 10:28:54 -0600, "John" wrote:
I'm trying to use a Select Case in a Private Sub Worksheet_Change event to
do the following:
if I type w in a cell in col B, I want to replace it with WIDGETS
if I type g in a cell in col B, I want to replace it with GIDGETS
seems like it should be simple but I can't come up with the code.
Try this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(ActiveSheet.Range("B:B"), Target) Is Nothing Then
Select Case Target.Value
Case "w"
Target.Value = "WIDGETS"
Case "g"
Target.Value = "GIDGETS"
End Select
End If
End Sub
Hope this helps / Lars-Åke
|