View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
honeybee129 honeybee129 is offline
external usenet poster
 
Posts: 1
Default how do i fill cells with random color?

This works if you just want a random color of the first 5 colors in the color
index list, but if I wanted a radom color out of a specific 5 colors how
could I adapt this? The 5 color indexes I want a 3,4,5,6, and 29.

"N10" wrote:


"Casey" wrote in message
...
I am trying to fill a grid of equal sized cells with random colors, or
colors
attached to a random number. I can fill the grid with random numbers
easily
enough, it's the colors i want.
Thanx....Casey



Hi Casey

Try this then adpat to your needs


Sub colorit()


Dim task As Range
Dim myvalue
Set task = Range("A1:l32")


For y = 1 To 5

For Each Cell In task
Randomize

myvalue = Int((56 * Rnd) + 1)

Cell.Interior.ColorIndex = myvalue

Next

Next

'
End Sub