LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Color constants in VBA

Thank you Gord, this may be the handiest of all the solutions.

MT

Gord Dibben wrote:

Mark

Couple of macros for colors listing.

Sub colors56()
'David McRitchie
'57 colors, 0 to 56
'needs ATP loaded
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Long
Dim str0 As String, Str As String
Sheets.Add
For i = 0 To 56
Cells(i + 1, 1).Interior.ColorIndex = i
Cells(i + 1, 1).Value = "[Color " & i & "]"
Cells(i + 1, 2).Font.ColorIndex = i
Cells(i + 1, 2).Value = "[Color " & i & "]"
str0 = Right("000000" & Hex(Cells(i + 1, 1).Interior.Color), 6)
'Excel shows nibbles in reverse order so make it as RGB
Str = Right(str0, 2) & Mid(str0, 3, 2) & Left(str0, 2)
'generating 2 columns in the HTML table
Cells(i + 1, 3) = "#" & Str & "#" & Str & ""
Cells(i + 1, 4).Formula = "=Hex2dec(""" & Right(str0, 2) & """)"
Cells(i + 1, 5).Formula = "=Hex2dec(""" & Mid(str0, 3, 2) & """)"
Cells(i + 1, 6).Formula = "=Hex2dec(""" & Left(str0, 2) & """)"
Cells(i + 1, 7) = "[Color " & i & ")"
Next i
done:
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

Sub ListColorIndexes()
'John Walkenbach
Dim Ndx As Long
Sheets.Add
For Ndx = 1 To 56
Cells(Ndx, 1).Interior.ColorIndex = Ndx
Cells(Ndx, 2).Value = Hex(ThisWorkbook.Colors(Ndx))
Cells(Ndx, 3).Value = Ndx
Next Ndx
End Sub

Gord Dibben Excel MVP

On Mon, 19 Jul 2004 19:55:30 -0700, Mark Tangard
wrote:


Hm. Actually it still doesn't come up in my VBA Help (XL 2000)....

These do work; but I was hoping to find the constants for all 40 of the
colors that can be applied to a cell interior from the toolbar dropdown.
Are these not all available as VBA constants?

TIA




 
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
Array Constants kittronald Excel Worksheet Functions 0 June 15th 11 12:04 AM
Constants in Excel Sharon Excel Discussion (Misc queries) 0 July 24th 08 02:38 PM
How to get a dump of Fill Color & Font VBA Constants? EagleOne Excel Discussion (Misc queries) 3 August 17th 06 08:17 PM
vba constants for excel diver Excel Discussion (Misc queries) 2 August 25th 05 07:51 PM
constants Confused Excel Discussion (Misc queries) 3 December 2nd 04 05:05 PM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"