LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Brian in FT W.
 
Posts: n/a
Default macro used to change colors

I'm trying to write an event macro for a worksheet that will change a cell's
color based on the outcome of various formulas.

I can get the Conditional Format to work for 3 items, however I have 4
variables.

If a number is between 4-3.5, Blue
If a number is between 3.49-2.5, Green
If a number is between 2.49-1.10, Yellow
If a number is between 1.09-0, Red

Below is what I tried to use, and I assume that is is completely wrong.

Can anyone offer a solution or advice? Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
'
Dim vNumber As String
Dim vColor As Integer
Dim cRange As Range
Dim cell As Range

Set cRange = Intersect(Range("A1:M99"), Range(Target(1).Address))
If cRange Is Nothing Then Exit Sub


vNumber = vNumber(Left(cell.Value & " ", 1))

vColor = 0
Select Case vNumber
Number "4.0:3.5"
vColor = 5
Number "3.499999:2.5"
vColor = 4
Number "2.49999:1.10"
vColor = 6
Number "1.09999:0"
vColor = 3

End Select
Application.EnableEvents = False
cell.Interior.ColorIndex = vColor
Application.EnableEvents = True
End Sub
 
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 do I change macro text with another macro? Eric Excel Discussion (Misc queries) 4 April 27th 05 11:20 PM
Change caption on a macro button gbeard Excel Worksheet Functions 3 April 21st 05 01:43 PM
How to change macro so it performs actions on ACTIVE sheet? Tom9283 Excel Discussion (Misc queries) 6 April 15th 05 07:32 AM
how do i change the expense statement template macro Mad2691 Excel Worksheet Functions 1 January 28th 05 01:21 PM
Where to stick macro to change default comment font? [email protected] Excel Discussion (Misc queries) 1 January 1st 05 12:57 AM


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