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 |
All times are GMT +1. The time now is 09:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com