【发布时间】:2017-12-27 23:52:50
【问题描述】:
我正在尝试编写一个程序,该程序循环遍历每个表中的每一行(每张表一个表),以便对其进行颜色编码,类似于条件格式。这不会移动到下一张纸,所以它只会对我打开的纸进行颜色编码。我希望它自动移动到下一个。任何输入表示赞赏。
Dim ccShipDate As Variant
Dim ccRow As Integer
Dim wsht As Worksheet
ccRow = 2
ccShipDate = Cells(ccRow, 6)
For Each wsht In Worksheets
If wsht.Name = "ManualReview" Or wsht.Name = "Filter" Or wsht.Name = "MRF" Or wsht.Name = "ModStd" Then
With Worksheets(wsht.Name)
' loops through "Actual Ship Date" column until empty
' past or today = red
' one day away = yellow
' more than one day = green
Do Until IsEmpty(ccShipDate)
If DateDiff("d", Date, ccShipDate) <= 0 Then
Cells(ccRow, 3).Interior.ColorIndex = 3
ElseIf DateDiff("d", Date, ccShipDate) = 1 Then
Cells(ccRow, 3).Interior.ColorIndex = 6
ElseIf DateDiff("d", Date, ccShipDate) > 1 Then
Cells(ccRow, 3).Interior.ColorIndex = 4
End If
ccRow = ccRow + 1
ccShipDate = Cells(ccRow, 6).Value
Loop
End With
End If
Next wsht
结束子
【问题讨论】:
-
使用
With时,您需要将所有链接的子项附加到.。所以.Cells(ccRow, 3).Interior...