Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help for a macro change cell colour under many conditions


please i need help.
If anyone can, i need a macro to colour a cell under some conditions.
e.g.
if (a1 and c<1) then cell "blue"
if (a<1 and d<1) then cell "green"
if (a1 and d=1) then cell "red"
if (c1 and e=1) then cell "yellow".

thanks, jim


--
dpjim
------------------------------------------------------------------------
dpjim's Profile: http://www.excelforum.com/member.php...o&userid=25143
View this thread: http://www.excelforum.com/showthread...hreadid=386388

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Help for a macro change cell colour under many conditions

Think you are looking for something like this.

Sub Collor()

Dim Rng As Range


With Worksheets("blad1")
Set Rng = Range("A1:D12") ''your range where to lool

End With
Dim CL As Object

Selection.Cells(1).Select
Rng.Select
Selection.Interior.ColorIndex = xlNone

For Each CL In Selection.Cells
Select Case CL.Value
Case (a 1 And c < 1)
CL.Interior.ColorIndex = 3
Case (a < 1 And d < 1)
CL.Interior.ColorIndex = 4

Case Else '----- color red = 3
CL.Interior.ColorIndex = xlNone
End Select
Next

'----- color white = 2
'----- color Green = 4

Selection.Cells(1).Select

End Sub

Chris

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
Change Tab colour using Macro Rajat Excel Worksheet Functions 4 October 24th 06 02:31 PM
change a cell background colour to my own RGB colour requirements Stephen Doughty Excel Discussion (Misc queries) 4 June 16th 06 01:08 PM
formula help to change row colour automatically by some conditions Aarif Excel Worksheet Functions 6 March 17th 06 03:51 PM
Change cell colour according to conditions 696796[_2_] Excel Programming 0 November 2nd 04 09:01 AM
Change cell colour according to conditions 696796 Excel Programming 1 November 2nd 04 08:50 AM


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