Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Font color setting problem


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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Font color setting problem

The ColorPalette for ColorIndex only has 56 colors. This will change so fast
that you will only see the first and last colors.

For Count = 1 To 56

Sheets("Sheet3").Range("B5").Font.ColorIndex = Count
Count = Count + 1
Next

" 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Font color setting problem

This is because the color index only goes up to 56. The error occurs when
you're trying to set the index to 57.

See here.
http://www.mvps.org/dmcritchie/excel...htm#colorindex


wrote in message
ups.com...

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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Font color setting problem

I believe there are only 56 colors. To see all of them:

Sub test()
For Count = 1 To 56
Sheets("Sheet3").Select
Range("B" & Count + 4).Interior.ColorIndex = Count
Next Count
End Sub





--
Hope that helps.

Vergel Adriano


" 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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with setting Interior Color in VBA cneumann Excel Programming 4 December 14th 05 03:37 PM
Problem with setting Interior Color in VBA cneumann Excel Programming 2 December 13th 05 10:56 PM
Problem setting font size Edward Ulle Excel Programming 2 March 3rd 05 03:23 PM
Problem in setting Cell Interior Color filling. Venkatachalam Excel Programming 1 September 29th 04 07:13 PM
vba: setting font color to entire sheet chick-racer[_35_] Excel Programming 3 November 17th 03 04:34 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"