Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Functon to fill cell with color

I know this has been asked before but I could not find a good answer
searching the archives.
I have a function that uses multiple IF-Then Statements. I want to
return text and a fill color to the cell based on these logical
condtions. I have about 20 logical statements to the Conditional
Formating will not work.

What are the basic code statements for this color fill?

Thanks
Steve

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Functon to fill cell with color


Heres a small worked solution for filling colour on specific text. Just
paste this code into the sheet your using and modify!

Hope it helps!

Simon

Sub people()

Dim rng
Dim mycell
Set rng = Range("A1:H20")
For Each mycell In rng
If mycell = "Fred" Then
f

ElseIf mycell = "Bob" Then
B

ElseIf mycell = "john" Then
J
ElseIf mycell = "" Then
Exit Sub


End If
Next mycell
End Sub
Sub f()
With Selection.Interior
..ColorIndex = 3
..Pattern = xlSolid
..PatternColorIndex = xlAutomatic

End With
End Sub
Sub J()

With Selection.Interior
..ColorIndex = 12
..Pattern = xlSolid
..PatternColorIndex = xlAutomatic
End With
End Sub
Sub B()
With Selection.Interior
..ColorIndex = 22
..Pattern = xlSolid
..PatternColorIndex = xlAutomatic
End With
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=490047

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Functon to fill cell with color

You use the Range Objects Interior.Color or Interior.ColorIndex
Property.

eg...

Application.ActiveCell.Interior.Color = vbYellow

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
How do I fill one cell color with text html/rgb color from another thewris Excel Discussion (Misc queries) 2 January 22nd 09 12:24 AM
How to set the default color for fill in functon? Eric Excel Discussion (Misc queries) 5 May 16th 06 03:36 AM
How to set the default color for fill in functon? Eric Setting up and Configuration of Excel 3 May 15th 06 03:09 PM
Fill color in a cell fastballfreddy Excel Discussion (Misc queries) 2 May 9th 06 08:51 PM
Cell Fill Color and text color - changes for recipient Shadowman13 Excel Discussion (Misc queries) 0 March 8th 06 11:32 PM


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