View Single Post
  #2   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

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