G
Guest
Hi All
I have a great code that replaces characters with symbols - and it works
brilliantly, until I select multiple cells on the worksheet and hit the
delete key.
I then get a "Run-time error '13': Type mismatch" error message.
Can someone tell me what I need to add to this code to stop the error if a
user hits the delete key?
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Target
Dim s As String
s = r.Value
s = Replace(s, "[", ChrW(780))
s = Replace(s, "]", ChrW(768))
s = Replace(s, "<", ChrW(772))
s = Replace(s, ">", ChrW(769))
s = Replace(s, "~", ChrW(776))
Application.EnableEvents = False
r.Value = s
Application.EnableEvents = True
End Sub
I have a great code that replaces characters with symbols - and it works
brilliantly, until I select multiple cells on the worksheet and hit the
delete key.
I then get a "Run-time error '13': Type mismatch" error message.
Can someone tell me what I need to add to this code to stop the error if a
user hits the delete key?
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Target
Dim s As String
s = r.Value
s = Replace(s, "[", ChrW(780))
s = Replace(s, "]", ChrW(768))
s = Replace(s, "<", ChrW(772))
s = Replace(s, ">", ChrW(769))
s = Replace(s, "~", ChrW(776))
Application.EnableEvents = False
r.Value = s
Application.EnableEvents = True
End Sub