Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
If Then Question from Newbie. . . hospitalgreg Excel Discussion (Misc queries) 6 October 16th 06 08:16 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
newbie question vapor77 New Users to Excel 5 February 4th 06 12:08 AM
Newbie Question Pete B Excel Discussion (Misc queries) 0 December 29th 05 11:27 AM


All times are GMT +1. The time now is 09:37 PM.

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"