samuelwright
11-10-2005, 07:44 AM
Hello all:hi:
I am trying to compare 2 columns of dates in a spreadsheet and if the second column is 3 months older than the first column, then it changes the background colour. I have the following, but to no avail! Please help!
Private Sub openbutton_click() ' the code below happens whenever the button is clicked
'Declarations
Dim i As Integer
Dim valueA As Date
Dim valueB As Date
For i = 1 To 6
valueA = Sheet1.Cells(i, 4)
valueB = Sheet1.Cells(i, 3)
If valueA > valueB + 90 Then
Cells(i, 2).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
Next i
End Sub
I have four columns, 1st column is one date, second column is another date, then the 3rd and fourth columns are the dates again but formatted into normal numbers
Sam
I am trying to compare 2 columns of dates in a spreadsheet and if the second column is 3 months older than the first column, then it changes the background colour. I have the following, but to no avail! Please help!
Private Sub openbutton_click() ' the code below happens whenever the button is clicked
'Declarations
Dim i As Integer
Dim valueA As Date
Dim valueB As Date
For i = 1 To 6
valueA = Sheet1.Cells(i, 4)
valueB = Sheet1.Cells(i, 3)
If valueA > valueB + 90 Then
Cells(i, 2).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
Next i
End Sub
I have four columns, 1st column is one date, second column is another date, then the 3rd and fourth columns are the dates again but formatted into normal numbers
Sam