Just I have tried with VBA it seems to be working. You can change the range to suite your no of rows.<Pre>Sub Macro()
Dim Cel As Range
Dim Add$
Set Cel = Range("A4:K9")
For Each C In Cel
Add = C.Address
For I = 65 To 75
If Mid(Add, 2, 1) = Chr(I) Then
If C.Value = Empty Then
' Do nothing
ElseIf Range(Chr(I) & "1") - C > 365 Then
C.Interior.ColorIndex = 3
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range(Chr(I) & "1") - C > 305 And Range(Chr(I) & "1") - C< 366 Then
C.Interior.ColorIndex = 6
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range(Chr(I) & "1") - C<= 305 Then
C.Interior.ColorIndex = 4
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
End If
End If
If I = 65 Then I = 68
If I = 70 Then I = 74
Next I
If Mid(Add, 2, 1) = "B" Then
If C.Value = Empty Then
' Do nothing
ElseIf Range("B1") - C > 180 Then
C.Interior.ColorIndex = 3
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("B1") - C > 120 And Range("B1") - C< 181 Then
C.Interior.ColorIndex = 6
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("B1") - C<= 120 Then
C.Interior.ColorIndex = 4
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
End If
ElseIf Mid(Add, 2, 1) = "C" Then
If C.Value = Empty Then
' Do nothing
ElseIf Range("C1") - C > 90 Then
C.Interior.ColorIndex = 3
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("C1") - C > 15 And Range("C1") - C< 91 Then
C.Interior.ColorIndex = 6
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("C1") - C<= 15 Then
C.Interior.ColorIndex = 4
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
End If
ElseIf Mid(Add, 2, 1) = "D" Then
If C.Value = Empty Then
' Do nothing
ElseIf Range("D1") - C > 1 Then
C.Interior.ColorIndex = 3
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("D1") - C<= 1 Then
C.Interior.ColorIndex = 4
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
End If
ElseIf Mid(Add, 2, 1) = "G" Then
If C.Value = Empty Then
' Do nothing
ElseIf Range("G1") - C > 3650 Then
C.Interior.ColorIndex = 3
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("G1") - C > 3590 And Range("G1") - C< 3651 Then
C.Interior.ColorIndex = 6
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("G1") - C<= 3590 Then
C.Interior.ColorIndex = 4
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
End If
End If
For I = 72 To 73
If Mid(Add, 2, 1) = Chr(I) Then
If C.Value = Empty Then
' Do nothing
ElseIf Range(Chr(I) & "1") - C > 1825 Then
C.Interior.ColorIndex = 3
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range(Chr(I) & "1") - C > 1765 And Range(Chr(I) & "1") - C< 1826 Then
C.Interior.ColorIndex = 6
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range(Chr(I) & "1") - C<= 1765 Then
C.Interior.ColorIndex = 4
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
End If
End If
Next I
If Mid(Add, 2, 1) = "J" Then
If C.Value = Empty Then
' Do nothing
ElseIf Range("J1") - C > 1095 Then
C.Interior.ColorIndex = 3
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("J1") - C > 1035 And Range("J1") - C< 1096 Then
C.Interior.ColorIndex = 6
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
ElseIf Range("J1") - C<= 1035 Then
C.Interior.ColorIndex = 4
C.Interior.Pattern = xlSolid
C.Interior.PatternColorIndex = xlAutomatic
End If
End If
Next
End Sub</Pre>
Book1.xls |
---|
|
---|
| A | B | C | D | E | F | G | H | I | J | K |
---|
1 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 | 13-Oct-02 |
---|
2 | 365 | 180 | 90 | 1 | 365 | 365 | 3650 | 1825 | 1825 | 1095 | 365 |
---|
3 | EXP1YR | EXP6MONTHS | EXPatbeginningofevery1/4 | EXPifOlderthantoday()date | EXP1YR | EXP1YR | EXP10YR | EXP5YRS | EXP5YRS | EXP3YR | EXP1YR |
---|
4 | 6-May-02 | 17-Sep-02 | 17-Jan-02 | 6-Jun-03 | 22-May-02 | | 9-Jun-94 | 26-Apr-02 | 1-Sep-96 | 29-Nov-00 | 2-Sep-01 |
---|
5 | 30-Dec-01 | 17-Sep-02 | 17-Apr-02 | 1-Dec-02 | 22-Sep-01 | 1-Nov-01 | 29-Jun-98 | 19-Sep-01 | 29-Aug-00 | 24-Apr-00 | 5-Jun-02 |
---|
6 | 7-Oct-02 | 7-Aug-02 | | | 9-Jul-02 | 10-Jan-01 | 9-Jul-02 | 2-Jul-02 | 6-Sep-00 | | 11-Jul-00 |
---|
7 | 10-May-02 | 13-May-02 | 18-Jul-02 | 8-Jul-02 | 22-May-02 | 19-Dec-01 | 11-Aug-00 | 22-May-02 | 19-Jan-96 | 17-Nov-96 | 5-Jun-02 |
---|
8 | 26-Apr-01 | | | 2-May-03 | 15-Sep-01 | 19-Dec-01 | 28-Feb-00 | 26-Apr-02 | 13-Aug-01 | 24-Mar-92 | |
---|
9 | 28-Aug-99 | 17-Jan-02 | 18-Oct-02 | 26-Mar-03 | 22-May-02 | 18-Dec-01 | 23-Aug-00 | 6-Apr-01 | 28-Feb-01 | 28-Feb-01 | 9-Jul-02 |
---|
|
---|
You can copy this code into workbook open event.
This message was edited by gnaga on 2002-10-13 10:45