pacfleck
09-19-2009, 06:08 AM
Does anybody knows what is the problem with this code:
k = RGB(255,0,0)
For a = 5 To 7
For Each c In Worksheets(a).Range(Worksheets(a).Cells(5, 4), Worksheets(a).Cells(5 + Worksheets(2).Cells(1, 1), 24))
If c.Font.Color = k Then
If Not (Range("D:D").Find(c.Value) Is Nothing) Then
If Worksheets(4).Cells(Worksheets(4).Range("d:d").Find(c.Value).Row, 8) = _
Worksheets(a).Cells(c.Row, 3) Then
c.Font.Color = RGB(0, 0, 0)
Else
Cells(Range("d:d").Find(c).Row, 8).Font.Color = RGB(255, 0, 0)
End If
End If
End If
Next
Next
I'm having problem with this part: If Not (Range("D:D").Find(c.Value) Is Nothing) Then
It never found what should be found. By the way, it is a date what it should look for. The "c.value" it is a date.
I have 7 sheets. In the sheet 4, there is a column, in the code you can see range("D:D"). Here I have some dates. These dates are in the sheets 5, 6 and 7 too. In the sheets 5, 6 and 7 there are a lot of dates, much more than exists in the sheet 4. The code should look for dates that are with the color red ("RGB(255,0,0)") in the sheets 5, 6 and 7. Than, when it found a date with this color, it have to look in the sheet 4 and confirm that this date really exists there. Now it should change the color to black in the date that is in the sheets 5, 6 or 7. The problem that I'm having is that it found the cells that the color of the font is red in the sheets 5, 6 and 7, but when it have to look for this date in the sheet 4, it doesn't found anything.
k = RGB(255,0,0)
For a = 5 To 7
For Each c In Worksheets(a).Range(Worksheets(a).Cells(5, 4), Worksheets(a).Cells(5 + Worksheets(2).Cells(1, 1), 24))
If c.Font.Color = k Then
If Not (Range("D:D").Find(c.Value) Is Nothing) Then
If Worksheets(4).Cells(Worksheets(4).Range("d:d").Find(c.Value).Row, 8) = _
Worksheets(a).Cells(c.Row, 3) Then
c.Font.Color = RGB(0, 0, 0)
Else
Cells(Range("d:d").Find(c).Row, 8).Font.Color = RGB(255, 0, 0)
End If
End If
End If
Next
Next
I'm having problem with this part: If Not (Range("D:D").Find(c.Value) Is Nothing) Then
It never found what should be found. By the way, it is a date what it should look for. The "c.value" it is a date.
I have 7 sheets. In the sheet 4, there is a column, in the code you can see range("D:D"). Here I have some dates. These dates are in the sheets 5, 6 and 7 too. In the sheets 5, 6 and 7 there are a lot of dates, much more than exists in the sheet 4. The code should look for dates that are with the color red ("RGB(255,0,0)") in the sheets 5, 6 and 7. Than, when it found a date with this color, it have to look in the sheet 4 and confirm that this date really exists there. Now it should change the color to black in the date that is in the sheets 5, 6 or 7. The problem that I'm having is that it found the cells that the color of the font is red in the sheets 5, 6 and 7, but when it have to look for this date in the sheet 4, it doesn't found anything.