Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default changing the color of a cell acording to its value

Hi.. I wanna a macro that can change the color of a cell acording to its
value. I've tried conditional formating, but it doesnt work cause I have 5
ranges of values.

from 0% to 79% = black with white font
from 80% to 84% = red with white font
from 85% to 87% = white with red font.
from 88% to 92% = yellow with red font
from 92% to 100% = green with white font

Could you helpme??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,722
Default changing the color of a cell acording to its value

This will apply formatting to every cell in your current selection (I.e., if
you select range A1:D4, formatting will be applied to those 16 cells)

Sub CellColor()
for each cell in selection
If Cell.Value = 0 And Cell.Value <= 0.79 Then
'Black with white
Selection.Font.ColorIndex = 2
Selection.Interior.ColorIndex = 1
End If
If Cell.Value 0.79 And Cell.Value <= 0.84 Then
'Red with white
Selection.Font.ColorIndex = 2
Selection.Interior.ColorIndex = 3
End If
If Cell.Value 0.84 And Cell.Value <= 0.87 Then
'White with red
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = 2
End If
If Cell.Value 0.87 And Cell.Value <= 0.92 Then
'Yellow with red
Selection.Font.ColorIndex = 3
Selection.Interior.ColorIndex = 6
End If
If Cell.Value 0.92 And Cell.Value <= 1 Then
'Green with white
Selection.Font.ColorIndex = 2
Selection.Interior.ColorIndex = 10
End If
next cell
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Dani Lima" wrote:

Hi.. I wanna a macro that can change the color of a cell acording to its
value. I've tried conditional formating, but it doesnt work cause I have 5
ranges of values.

from 0% to 79% = black with white font
from 80% to 84% = red with white font
from 85% to 87% = white with red font.
from 88% to 92% = yellow with red font
from 92% to 100% = green with white font

Could you helpme??

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default changing the color of a cell acording to its value

Conditional formatting works for me in 2007.
--
Roland


"Dani Lima" wrote:

Hi.. I wanna a macro that can change the color of a cell acording to its
value. I've tried conditional formating, but it doesnt work cause I have 5
ranges of values.

from 0% to 79% = black with white font
from 80% to 84% = red with white font
from 85% to 87% = white with red font.
from 88% to 92% = yellow with red font
from 92% to 100% = green with white font

Could you helpme??

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
Changing the color of a cell based on the color of another cell. LATC Excel Discussion (Misc queries) 7 December 4th 09 09:49 PM
Chaging the color of a cell acording to its value Dani Lima[_2_] Excel Programming 3 February 10th 09 09:31 AM
Changing cell color by value jgaard Excel Worksheet Functions 2 February 17th 08 03:24 PM
I WANT DATA TO LINK WITH OTHER WORKBOOKS ACORDING TO CELL CONTENT. HUGO PIENAAR Excel Worksheet Functions 0 April 28th 06 02:45 PM
Changing cell color Kas Excel Programming 2 September 14th 05 09:40 PM


All times are GMT +1. The time now is 05:08 PM.

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"