View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
BC BC is offline
external usenet poster
 
Posts: 26
Default Type Mismatch Error when Inserting a new row

Hi,

I have written some conditional formatting code which changes the background
color of certain cells based on their value. This works perfect, until a user
tries to insert a new row into the table - when they do this they received a
Run Time Error '13' - Type Mismatch.

The code I am using is shown below:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer

If Not Intersect(Target, Range("Table")) Is Nothing Then
Select Case Target
Case 1 To 5
icolor = 5
Case 6 To 10
icolor = 6
Case 11 To 15
icolor = 46
Case 16 To 20
icolor = 3
Case 21 To 25
icolor = 13
Case Else
'Whatever
End Select

Target.Interior.ColorIndex = icolor
End If

End Sub


Any help would be very much appreciated,

Thanks

BC