我正在使用下面的代码在我的电子表格中更改日期后插入整个黄色行并且它工作得很好但是,我现在想要在A列中的黄色高位行中实际添加DAY随着日期的变化。我非常感谢任何指导。
Dim iRow As Integer, iCol As Integer
Dim oRng As Range
Set oRng = Range("L7:L500")
iRow = oRng.Row
iCol = oRng.Column
Do
'
If iRow = 500 Then
End
ElseIf Cells(iRow, iCol).Text = "" Then
iRow = iRow + 1
ElseIf Cells(iRow + 1, iCol).Text = "" Then
If Left(Cells(iRow + 2, iCol), 14) <> Left(Cells(iRow, iCol), 14) Then
Cells(iRow + 2, iCol).EntireRow.Insert shift:=xlDown
Range(Cells(iRow + 2, 1), Cells(iRow + 2, 22)).Interior.Color = vbYellow
' Rows(iRow + 2).Interior.Color = vbYellow
iRow = iRow + 3
Else
iRow = iRow + 2
End If
ElseIf Left(Cells(iRow + 1, iCol), 14) <> Left(Cells(iRow, iCol), 14) Then
Cells(iRow + 1, iCol).EntireRow.Insert shift:=xlDown
Range(Cells(iRow + 1, 1), Cells(iRow + 1, 22)).Interior.Color = vbYellow
' Rows(iRow + 1).Interior.Color = vbYellow
iRow = iRow + 2
Else
iRow = iRow + 1
End If
'
Loop
End Sub
答案 0 :(得分:1)
插入行后添加此行
Range(Cells(iRow + 1, 1), Cells(iRow + 1, iCol)).Interior.Color = vbYellow
第一个Cell是Row的开头,第二个Cell是行的结尾。如果你想要整行,那么就这样做
Rows(iRow + 1).Interior.Color = vbYellow