Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 25
Default Color of cell.

Hello,

how can I identify which "fill color" is used on cell.

For example:

whatColor = range("A1")
If whatColor = 1 then ....


thanks Tom


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Color of cell.

If Range("A1").Interior.ColorIndex = 1 then


Mangesh



"Tom" wrote in message
...
Hello,

how can I identify which "fill color" is used on cell.

For example:

whatColor = range("A1")
If whatColor = 1 then ....


thanks Tom




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Color of cell.

Hi Tom,

Sub Tester()
Dim rng As Range
Dim iColor As Long

Set rng = Range("A1")

iColor = rng.Interior.ColorIndex

If iColor = 6 Then
'do something
Else
'do something else
End If

End Sub

---
Regards,
Norman



"Tom" wrote in message
...
Hello,

how can I identify which "fill color" is used on cell.

For example:

whatColor = range("A1")
If whatColor = 1 then ....


thanks Tom



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Color of cell.

if you use the .Color property, then you avoid possible issues where
different users have changed their color palette - to a degree.
Also, using SELECT CASE can make your code a little more flexible...

Option Explicit
Enum eColors
Red = 3
Blue = 5
Green = 4
Brown = 9
End Enum
Sub Test()
Select Case Selection.Interior.ColorIndex
Case eColors.Blue
'process blue cell
Case eColors.Brown
'process brown cell
' etc etc
Case Else
' color not recognised
End Select
End Sub
Sub ShowColors()
Dim index As Long
Range("A1:B57").Clear
For index = 0 To 56
Cells(index + 1, 1) = index
Cells(index + 1, 2).Interior.ColorIndex = index
Next
End Sub



"Mangesh Yadav" wrote:

If Range("A1").Interior.ColorIndex = 1 then


Mangesh



"Tom" wrote in message
...
Hello,

how can I identify which "fill color" is used on cell.

For example:

whatColor = range("A1")
If whatColor = 1 then ....


thanks Tom





Reply
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
Can't format cell color/text color in Office Excel 2003 in fil Tony S Excel Discussion (Misc queries) 1 December 21st 07 01:41 PM
Excel: Syntax to change cell color based on color of another cell davew18 Excel Worksheet Functions 1 January 4th 07 01:24 PM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
Default Border, Font Color, and Cell Background Color Elijah Excel Discussion (Misc queries) 1 October 28th 05 04:10 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM


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

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

About Us

"It's about Microsoft Excel"