Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color Cells via VBA

I'm trying to set the background color (highlight) cells
in my spreadsheet based on the value of a cell. I haven't
been able to find a way to access this programmatically,
and I don't want to do it by hand every time the value
changes. Any clues?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Color Cells via VBA

If you have 3 or fewer conditions try formatconditional format. If not come
back for code.

--
Don Guillett
SalesAid Software

"Mike Eckardt" wrote in message
...
I'm trying to set the background color (highlight) cells
in my spreadsheet based on the value of a cell. I haven't
been able to find a way to access this programmatically,
and I don't want to do it by hand every time the value
changes. Any clues?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color Cells via VBA

this could be one example

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Value = 1 Then
Target.Cells.Interior.ColorIndex = 1
ElseIf Target.Value = 2 Then
Target.Cells.Interior.ColorIndex = 4
Else
Target.Cells.Interior.ColorIndex = 3
End If

End Sub

note: the code has to be placed in the sheet module


Alternatively you could also use conditional formatting

- Mangesh


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

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 to color automatically color code sums in cells kuroitenpi Charts and Charting in Excel 1 November 29th 06 03:16 AM
How do I apply color in cells ..color now shown only in print prev bonadimi Excel Worksheet Functions 1 April 25th 06 07:34 PM
Excel 2003 will not display color fonts or color fill cells DaveC Excel Worksheet Functions 1 April 11th 05 04:38 PM
Color Formatted Cells not showing color jilary2 Excel Worksheet Functions 1 February 22nd 05 07:31 PM
My excel 2003 wont let me fill cells with color or color the tabs. trizog New Users to Excel 2 February 22nd 05 06:43 PM


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