LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default VB Code Question

Run this macro.

Sub ListColorIndexes()
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

On Tue, 3 Mar 2009 13:56:30 -0800, Stan
wrote:

Works Great! Do you know how I can tell what the ColorIndex is for each color?

I see that 3 = Red but I also need Green, Blue, Orange, and Yellow.

"Gord Dibben" wrote:

Sub do_something()
If ActiveCell.Interior.ColorIndex = 3 Then
MsgBox "What now?" 'run a macro or do something
Else
MsgBox "Not Red!" 'do nothing and exit
End If
End Sub


Gord Dibben MS Excel MVP

On Tue, 3 Mar 2009 12:57:01 -0800, Stan
wrote:

Can someone help me by telling me how I can refer to a cell's color and the
perform an action? In other words, if a cell is red, then docmd.xxxxx?

Many thanks!




 
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
VBA code question peyman Excel Discussion (Misc queries) 5 February 5th 09 12:04 AM
vb code question Stan Excel Programming 0 April 28th 08 06:49 PM
vb code question Stan Excel Discussion (Misc queries) 8 April 25th 08 10:43 PM
vb code question Stan Excel Discussion (Misc queries) 1 April 25th 08 09:45 PM


All times are GMT +1. The time now is 12:46 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"