Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You use the Range Objects Interior.Color or Interior.ColorIndex
Property. eg... Application.ActiveCell.Interior.Color = vbYellow |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I fill one cell color with text html/rgb color from another | Excel Discussion (Misc queries) | |||
How to set the default color for fill in functon? | Excel Discussion (Misc queries) | |||
How to set the default color for fill in functon? | Setting up and Configuration of Excel | |||
Fill color in a cell | Excel Discussion (Misc queries) | |||
Cell Fill Color and text color - changes for recipient | Excel Discussion (Misc queries) |