Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Runtime error 13 Colour formatting

Status
Not open for further replies.

kitackers

MIS
Apr 16, 2004
33
GB
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
 

Hi,

Please post VBA code questions in forum707.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top