PC Review


Reply
Thread Tools Rate Thread

code to choose tab color?

 
 
Mekinnik
Guest
Posts: n/a
 
      30th Dec 2007
How can I make the following line of code randomly choose the tab color
index? I would like the code automaticlly color the tab not me choose it.

..Tab.ColorIndex = 3
 
Reply With Quote
 
 
 
 
Mekinnik
Guest
Posts: n/a
 
      30th Dec 2007
I have tried this line of code I found in the community forums, but it does
not produce random numbers as far as color numbers go, when I reset the the
macro and start again it produces the same number/color. Does anyone have any
suggestions to this problem?

n = Int((54 * Rnd) + 1)
..Tab.ColorIndex = n

"Mekinnik" wrote:

> How can I make the following line of code randomly choose the tab color
> index? I would like the code automaticlly color the tab not me choose it.
>
> .Tab.ColorIndex = 3

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      30th Dec 2007
It works for me.

1. Did you specify the sheet?...
Worksheets(1).Tab.ColorIndex = n
2. Are you using Excel 2002 or a later version?
3. Is N declared as a Long?
4. Try using "Randomize" as a single line just before "n =..."
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Mekinnik"
wrote in message
I have tried this line of code I found in the community forums, but it does
not produce random numbers as far as color numbers go, when I reset the the
macro and start again it produces the same number/color. Does anyone have any
suggestions to this problem?

n = Int((54 * Rnd) + 1)
..Tab.ColorIndex = n

"Mekinnik" wrote:

> How can I make the following line of code randomly choose the tab color
> index? I would like the code automaticlly color the tab not me choose it.
>
> .Tab.ColorIndex = 3

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert HTML Color code to Access Color Code Malcolm Hind Microsoft Access Getting Started 3 24th Oct 2009 12:17 AM
How do I choose font color while tracking changes. CapitalCity Microsoft Excel Misc 1 12th Aug 2009 03:22 AM
How To Choose The Best Color Contact Lenses xikom03@yeah.net Printers 4 19th Feb 2008 05:57 PM
Choose printout color or b/w using vba Jonsson Microsoft Excel Programming 2 19th Jul 2005 08:53 PM
CommonDlg Choose color 123 Microsoft Access Form Coding 6 9th Feb 2004 11:05 AM


Features
 

Advertising
 

Newsgroups
 


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