1
以下Excel VBA代码在顶行与列E和F 开始和结束日期,然后它突出了细胞产生各行中的颜色栏比较日期。Excel VBA中 - 跳过行已经强调
如何跳过已突出显示的行并在输入有效日期后自动创建彩色栏?提前感谢您提供的任何帮助。
Set Rng = Range(Range("E7"), Range("E" & RowS.Count).End(xlUp)) 'The start end dates are in columns E and F
DateRng.Resize(Rng.Count + 1).Interior.ColorIndex = xlNone
For Each Dn In Rng
For Each Ac In DateRng
If Ac >= Dn And Ac <= Dn.Offset(0, 1) Then
Ac.Offset(Dn.Row - 2 - 0).Interior.ColorIndex = Range("D4").Value
Ac.Offset(Dn.Row - 2 - 0).Borders(xlEdgeTop).Color = vbWhite
Ac.Offset(Dn.Row - 2 - 0).Borders(xlEdgeTop).LineStyle = xlContinuous
Ac.Offset(Dn.Row - 2 - 0).Borders(xlEdgeTop).Weight = xlThick
Ac.Offset(Dn.Row - 2 - 0).Borders(xlEdgeBottom).Color = vbWhite
Ac.Offset(Dn.Row - 2 - 0).Borders(xlEdgeBottom).LineStyle = xlContinuous
Ac.Offset(Dn.Row - 2 - 0).Borders(xlEdgeBottom).Weight = xlThick
End If
Next Ac
Next Dn
V
向我们展示了完整的代码。 DateRng在哪里宣布?你也应该使用显式的选项来强制变量声明 – JMax 2012-02-18 11:33:33