Re: *** Tab Color, Excel 2000 & 2003



Hello,

Example one worked.

you could declare an array variable in your code like this:

    Dim pvarColorIndex as Variant

Then you could assign your ColorIndex Values to it like this (before the
loop):

    pvarColorIndex = Array(44, 33, 22, 8, 16, 56, ...)

Make sure that you enter the ColorIndex numbers in the order you want the
sheets colored.

Then inside your loop, you could assign the color like this:

    Worksheets(i).Tab.ColorIndex = pvarColorIndex(i - 1)

I put the "i - 1" in there because arrays are usually 0 based...ie a 30
element array has elements numbered 0 to 29.  I believe you can change that
with an "Option Base" (or something like that) statement in the General
Declarations.  Look up "Using Arrays" in VBA Help for more info.  I don't
recall if sheets are 0 based or 1 based.  Expierment with it and see.

Example two did not work and this is my macro: How can it be modified
to work?

Sub WorkSheetsTabColor3()
'Work*** Tab Color Assigned in Array
'Define Variables
Dim i As Integer
'Explicitly declare a 1-based 30 element integer array variable
Dim pintColorIndex(1 To 30) As Integer
'Sreen does not flash (Turn Screen Updating "OFF")
Application.ScreenUpdating = False
'Assignning array with Color Index Values
pintColorIndex = Worksheets("config").Range("I3:I32")
'''or use the following line
'pintColorIndex = Worksheets("config").Range("I3:I32").Value
'Changes Tab Color every other work*** 2-count
For i = 1 To Worksheets.Count
'Assignning each array color to work*** tab
Worksheets(i).Tab.ColorIndex = pintColorIndex(i)
'Continuing to next work***
Next i
'Turn Screen Updating "ON"
Application.ScreenUpdating = True
End Sub

You might also be able to do something like this:

    'Explicitly declare a 1-based 30 element integer array variable
    Dim pintColorIndex(1 to 30) as Integer
    pintColorIndex = Worksheets("config").Range("I3:I32")
    '''or use the following line
    'pintColorIndex = Worksheets("config").Range("I3:I32").Value

(haven't tested this code...don't know if you can assign values to an array
like this)

Then in your loop you can assign the color like this:

    Worksheets(i).Tab.ColorIndex = pintColorIndex(i)

Notice there is just an "i" in the array instead of "i - 1" because I
explicitly declared it as 1-based, not 0 based.


Thank you for your help,
jfcby
.


Loading