View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Jim May Jim May is offline
external usenet poster
 
Posts: 477
Default ??? How to get list of Color constants

Bob,
Thanks .. much appreciated - have printed-off
your comments to study and commit to memory later.
Jim

"Bob Phillips" wrote:

Hi Jim,

In the workbook that the code that uses it is also in.

It gets better.

Create a simple sub like so


Sub SetColour(cell As Range, colour As xlColorIndex)
cell.Interior.ColorIndex = colour
End Sub

then in the immediate window, type

SetColour Activecell,

when you type the colour, you will see a list pop, intellisense just as with
other parts of VBA :-). This will also happen when entering code normally.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jim May" wrote in message
news:ibSNg.14642$xk3.1671@dukeread07...
Bob,
Wasn't quite sure about use of enums, but I pasted the below into a
standard module; then only in the immediate window I entered:

Range("B4").Interior.ColorIndex = xlCIYellow

And it worked (suddenly my cell B4 turned yellow) Yikes,,,

My question is: If someone worked with and needed/wanted to
Use the this scheme index they would simply INCLUDE the 58 lines
As is into a standard module of either the: 1)Activeworkbook,
2)Personal.xls
Or 3)an add-in?

Thanks for your help,,
Jim May


"Bob Phillips" wrote in message
:

Here is an enumerated list which you can add to a module and then use

the
colour constant name.

Public Enum xlColorIndex
xlCIBlack = 1
xlCIWhite = 2
xlCIRed = 3
xlCIBrightGreen = 4
xlCIBlue = 5
xlCIYellow = 6
xlCIPink = 7
xlCITurquoise = 8
xlCIDarkRed = 9
xlCIGreen = 10
xlCIDarkBlue = 11
xlCIDarkYellow = 12
xlCIViolet = 13
xlCITeal = 14
xlCIGray25 = 15
xlCIGray50 = 16
xlCIPeriwinkle = 17
xlCIPlum = 18
xlCIIvory = 19
xlCILightTurquoise = 20
xlCIDarkPurple = 21
xlCICoral = 22
xlCIOceanBlue = 23
xlCIIceBlue = 24
'xlCIDarkBlue = 25
'xlCIPink = 26
'xlCIYellow = 27
'xlCITurquoise = 28
'xlCIViolet = 29
'xlCIDarkRed = 30
'xlCITeal = 31
'xlCIBlue = 32
xlCISkyBlue = 33
xlCILightGreen = 35
xlCILightYellow = 36
xlCIPaleBlue = 37
xlCIRose = 38
xlCILavender = 39
xlCITan = 40
xlCILightBlue = 41
xlCIAqua = 42
xlCILime = 43
xlCIGold = 44
xlCILightOrange = 45
xlCIOrange = 46
xlCIBlueGray = 47
xlCIGray40 = 48
xlCIDarkTeal = 49
xlCISeaGreen = 50
xlCIDarkGreen = 51
xlCIBrown = 53
xlCIIndigo = 55
xlCIGray80 = 56
End Enum



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jaylin" wrote in message
...

I have the following code with colorindx number 1 representing black

color,


May I know how do I get the related color constatn list (ie what

number =
what color) in VBA

With Selection.Interior
.ColorIndex = 1
End With

--
Thanks a million for your time and expert advice :-)
Jaylin
*****Jaylin Message ended*******