View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
geofflilley geofflilley is offline
external usenet poster
 
Posts: 1
Default Font color setting problem


;7516647 Wrote:
I am trying to set the color of a range of cells based on the number
of a looping variable (Count). The following code gives me an
error indicating that the color can't be set using a variable name.
What would be an alternate way to do this?


For Count = 1 To 60

Sheets("Sheet3").Select
Range("B5").Select
Selection.Font.ColorIndex = Count

Thanks.


I think what you probably want to do is something like this:

Sub setColor()
Sheets("Sheet1").Select
Range("B5").Select
For Count = 0 To 56
Selection.Font.ColorIndex = Count
ActiveCell.Offset(1, 0).Activate
Next
End Sub

Problem is that the colors only go up to 56. I suspect the error that
you're getting is "unable to set colorindex property of the Font class."
That's kinda misleading. You CAN use the counter as you outlined
above; the problem is that you're asking the code to set the ColorIndex
to a number that it can't do.

HTH

Cheers
Geoff


--
geofflilley