ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For Next only updating one row (https://www.excelbanter.com/excel-programming/430923-next-only-updating-one-row.html)

Gary McCarthy

For Next only updating one row
 
I am looking to change the font color to blue if the last update date (in
column 19) is greater than yesterday. I have the code below in the macro but
it only runs for the row that is selected. It doesn't run through rows 2 to
1000. Any help is appreciated.

For rwIndex = 2 To 1000
For colIndex = 19 To 19
With Worksheets("CC Routed Truck Loads").Cells(rwIndex, colIndex)
If .Value = "" Then
Exit For
Else
If .Value Int(Now()) - 3 Then
Selection.EntireRow.Font.ColorIndex = 5
End If
End If
End With
Next colIndex
Next rwIndex


Gary McCarthy

For Next only updating one row
 

Thanks to anyone who took a look at this, but I just realized I should remove
the word Selection. Works fine now.



"Gary McCarthy" wrote:

I am looking to change the font color to blue if the last update date (in
column 19) is greater than yesterday. I have the code below in the macro but
it only runs for the row that is selected. It doesn't run through rows 2 to
1000. Any help is appreciated.

For rwIndex = 2 To 1000
For colIndex = 19 To 19
With Worksheets("CC Routed Truck Loads").Cells(rwIndex, colIndex)
If .Value = "" Then
Exit For
Else
If .Value Int(Now()) - 3 Then
Selection.EntireRow.Font.ColorIndex = 5
End If
End If
End With
Next colIndex
Next rwIndex


Don Guillett

For Next only updating one row
 

If you have only ONE last update why look at all cells?
Sub colorlastupateincol19()
mc = 19
lr = Cells(Rows.Count, mc).End(xlUp).Row
If Cells(lr, mc) Date - 1 Then rows(lr).font.ColorIndex = 5
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Gary McCarthy" wrote in message
...
I am looking to change the font color to blue if the last update date (in
column 19) is greater than yesterday. I have the code below in the macro
but
it only runs for the row that is selected. It doesn't run through rows 2
to
1000. Any help is appreciated.

For rwIndex = 2 To 1000
For colIndex = 19 To 19
With Worksheets("CC Routed Truck Loads").Cells(rwIndex, colIndex)
If .Value = "" Then
Exit For
Else
If .Value Int(Now()) - 3 Then
Selection.EntireRow.Font.ColorIndex = 5
End If
End If
End With
Next colIndex
Next rwIndex




All times are GMT +1. The time now is 07:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com