LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Program cell background color

Here's a macro that can be easily extended should you need more than 3
colours

Sub colours()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
With Cells(i, "A")
Select Case .Value
Case "*": .Interior.ColorIndex = 3 'red
Case "**": .Interior.ColorIndex = 5 'blue
Case "***": .Interior.ColorIndex = 10 'green
End Select
End With
Next i

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Dave Peterson" wrote in message
...
As long as you don't exceed three possibilities, you could use a non-macro
approach.

You could use Format|Conditinal formatting...

Give it three conditions:
Cell value is ="*"
and a nice format
click Add
cell value is ="**"
and another nice format
click add
cell value is = "***"
and a last nice format

(Conditional formatting only supports 3 conditions, though.)

"nebb <" wrote:

My Excel worksheet has numerous cells that contain the same type formula
resulting in placing either *, or **, or *** in each of these cells.
The data on the sheet is changed each week such that any cell, in any
particular week, might contain any of the three possibilities.
I would like to be able to run a macro that would insert one background
color in each cell that contains one *, another color in those cells
that contain **, and still another background color in those cells that
contain ***.
Any help would be greatly appreciated.

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



 
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
Cell Background Color Joe Gieder Excel Worksheet Functions 4 July 15th 08 09:24 PM
cell background color and cell text color Jeff Klein Excel Worksheet Functions 1 November 1st 07 08:59 PM
Add background color to cell Rich K. Excel Discussion (Misc queries) 2 January 23rd 07 09:56 PM
Default Border, Font Color, and Cell Background Color Elijah Excel Discussion (Misc queries) 1 October 28th 05 04:10 PM
Set background color of a cell in VBA Cindy Excel Programming 9 January 16th 04 09:05 PM


All times are GMT +1. The time now is 10:56 PM.

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"