I've got a workbook with the enclosed code embedded to each worksheet, which format the cells depending on the data entered (I know the code isn't too tidy, I'm only doing this as a favour!!). When more than one cell is selected and data is deleted, I get a Runtime error 13, type mismatch. Gone through the various threads aren't can't find anything
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("e7:BN26")) Is Nothing Then
Select Case Target
Case ""
icolor = 2
Case "t"
icolor = 4
Case "T"
icolor = 4
Case "sd"
icolor = 24
Case "SD"
icolor = 24
Case "p"
icolor = 35
Case "P"
icolor = 35
Case "ob"
icolor = 3
Case "OB"
icolor = 3
Case "op"
icolor = 44
Case "OP"
icolor = 44
Case "o"
icolor = 26
Case "O"
icolor = 26
Case "c"
icolor = 34
Case "C"
icolor = 34
Case "s"
icolor = 36
Case "S"
icolor = 36
Case "h"
icolor = 28
Case "H"
icolor = 28
Case Else
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("e7:BN26")) Is Nothing Then
Select Case Target
Case ""
icolor = 2
Case "t"
icolor = 4
Case "T"
icolor = 4
Case "sd"
icolor = 24
Case "SD"
icolor = 24
Case "p"
icolor = 35
Case "P"
icolor = 35
Case "ob"
icolor = 3
Case "OB"
icolor = 3
Case "op"
icolor = 44
Case "OP"
icolor = 44
Case "o"
icolor = 26
Case "O"
icolor = 26
Case "c"
icolor = 34
Case "C"
icolor = 34
Case "s"
icolor = 36
Case "S"
icolor = 36
Case "h"
icolor = 28
Case "H"
icolor = 28
Case Else
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub