Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
newbie question (random colours)
Hi Sara-Jane
You can use the Rnd function to generate a random integer and the ColorIndex property to set the cells interior color. The ColorIndex property can also be used to set a cells border and font color. The following code sets the interior color of cell A1. Sub randomColor() Dim value as Integer Randomize ' Initialize random-number generator. ' Generate random value between 1 and 56. ' The default color palette has 56 colors. value = Int((56 * Rnd) + 1) Range("A1").Interior.ColorIndex = value End Sub Joe. "Sara-Jane" wrote in message ... Hello, can anyone help me, at the end of my macro, I need to put a random colour into a cell in an excel. How can I do this? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Real Newbie newbie question | New Users to Excel | |||
If Then Question from Newbie. . . | Excel Discussion (Misc queries) | |||
Newbie Question - Subtraction Formula Question | Excel Discussion (Misc queries) | |||
newbie question | New Users to Excel | |||
Newbie Question | Excel Discussion (Misc queries) |