View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Function in a VBA prog. or something like that

Bob Phillips pretended :
Why not use a worksheet change event?

--

HTH

Bob

"GS" wrote in message ...
Here's a good place to start. Make sure you have the correct cell active
when you run this code.

In a standard module:

Option Explicit

Sub SetCellColors()
Dim vH, vP, i As Long, lColor As Long
vH = ActiveSheet.Range("F7:F10")
vP = ActiveSheet.Range("D7:D10")
For i = LBound(vH) To UBound(vH)
Select Case (vH(i, 1) - vP(i, 1))
Case Is < -2: lColor = 111 'Albatros or better
Case -2: lColor = 232 'Eagle
Case -1: lColor = 193 'Birdie
Case 0: lColor = 174 'Par
Case 1: lColor = 235 'Bogey
Case 2: lColor = 124 'D.Bogey
Case Is 2: lColor = 227 'T.Bogey or worse
End Select
ActiveCell.Offset(1, i + 9).Interior.Color = lColor
Next 'i
End Sub

-- Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



That idea will cause the code to fire whenever changes occur. This may
not be what the OP wants since the result affects a cell relative to
the active cell at the time the code runs. Normally, I'd agree this is
te sort of thing I'd use the Change event for, but without any further
info it's hard to determine if that's a viable approach.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc