PDA

View Full Version : Run-time error for Highlighting



frubeng
05-25-2010, 03:37 AM
I get the following error message and have now idea why or how to fix it :(

Run-time error '-2147417848 (80010108)':
Method 'ColorIndex' of object 'Font' failed

Any ideas?


MODULE1:

Sub color_cells(fire_rng As Range)
For Each C In fire_rng
If IsNumeric(C.Offset(0, -3).Value) Then
If C.Value < 0 Then
Range(C, C.Offset(0, -4)).Interior.ColorIndex = 9
Range(C, C.Offset(0, -5)).Font.ColorIndex = 2
C.Offset(0, -5) = "HI"
C.Offset(0, -5).Interior.ColorIndex = 3
Else
Range(C, C.Offset(0, -4)).Interior.ColorIndex = 1
Range(C, C.Offset(0, -4)).Font.ColorIndex = 2
If Not C.Offset(0, -5).Value = "HI" _
And Not C.Offset(0, -5).Value = "LO" Then
C.Offset(0, -5).Interior.ColorIndex = 1
C.Offset(0, -5).Font.ColorIndex = 2
End If
End If
Next C
End Sub


It highlights the line with Font.ColorIndex

Sub main()
Call color_cells(ActiveSheet.Range("f2:f60"))
Call color_cells(ActiveSheet.Range("l2:L60"))
Call color_cells(ActiveSheet.Range("r2:r60"))
End Sub

SHEET1:

Private Sub Worksheet_calculate()
Call main
End Sub

So main is being called all the time as values in sheet columns F, L and R are changing often.

If i click debug, then try to resume, it says: Out of Memory...

I just restarted and got the same error.

Aussiebear
05-25-2010, 03:59 AM
Yes..... Don't bother closing the workbook and run like hell.

Aussiebear
05-25-2010, 04:06 AM
Seriously, what are we to make of your initial post? You failed to mention the section of code you were trying to run at the time of this error message, or even produce a sample workbook for us to view the how why when or oops factor, so how are we expected to provide you with an answer.

frubeng
05-25-2010, 04:19 AM
Seriously, what are we to make of your initial post? You failed to mention the section of code you were trying to run at the time of this error message, or even produce a sample workbook for us to view the how why when or oops factor, so how are we expected to provide you with an answer.

Yes sorry, added all the info, thanks for any help!

mdmackillop
05-25-2010, 07:47 AM
Your code will fail if C is in row 5 or above. There is then no c.offset(,-5).
A sample file would assist.