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: 395
Default Conditional formating using VBA

Open the VBE, insert a new module, and paste in the code. Then select and run
it.

Note that this is not dynamic like true "conditional formatting"; e.g. if
the cell values change, the colors will not change until the macro is run
again.

HTH,
Keith

Sub UpdateColors()

For i = 1 To 34

RowToFormat = i + 3
RowOfData = i + 42
'Sheet1.Range("A1").Interior.Color

DataValue = Sheets("Sheet1").Range("I" & RowOfData).Value

Select Case DataValue
Case Is < 0.5
Sheets("Sheet1").Range("I" & RowToFormat).Interior.Color = vbRed
Case Is <= 0.75
Sheets("Sheet1").Range("I" & RowToFormat).Interior.Color =
vbYellow
Case Is <= 0.9
Sheets("Sheet1").Range("I" & RowToFormat).Interior.Color = vbBlue
Case Is <= 1
Sheets("Sheet1").Range("I" & RowToFormat).Interior.Color = vbGreen
Case Else
Sheets("Sheet1").Range("I" & RowToFormat).Interior.Color =
xlAutomatic
End Select

Next

End Sub

"RedDevil" wrote:

Hello
I have to format cells (I4:J37) if cells (I43:J76) a
100%-91% (green)
90%-76% (blue)
75%-50% (yellow)
<50% (red)

How do I write that in VBA? (I am new to VBA so any help would be appreciated)

Many thanks
Tracey

 
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
Conditional Formating Alexa M. Excel Discussion (Misc queries) 7 January 21st 10 07:42 PM
conditional formating Jase Excel Discussion (Misc queries) 3 October 14th 08 07:40 PM
Conditional Formating JBoyer Excel Discussion (Misc queries) 3 July 8th 08 12:00 AM
Install dates formating using conditional formating? Jerry Eggleston Excel Discussion (Misc queries) 2 November 9th 05 05:49 PM
Conditional Formating carl Excel Worksheet Functions 0 August 4th 05 09:45 PM


All times are GMT +1. The time now is 01:27 AM.

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"