我想在选择标准满足时突出显示红色的行,但我发现在搜索程序的整个过程中没有选择任何单元格,我该怎么办?
Sub Main()
Dim celltxt As String
Dim cell As Range, cell2 As Range
Dim aMonthFromNow As Date
For Each cell In Range("M1:M" & Range("M" & Rows.Count).End(xlUp).Row)
aMonthFromNow = DateAdd("m", 1, Now)
If Month(cell) = Month(aMonthFromNow) And Day(cell) = Day(aMonthFromNow) Then
MsgBox "cc 1 month notice at " & cell.Address
End If
Next
For Each cell In Range("M1:M" & Range("M" & Rows.Count).End(xlUp).Row)
If cell = DateAdd("m", 2, Left(Now, 10)) Then
MsgBox "ee 2 months notice at " & cell.Address
End If
Next
End Sub
答案 0 :(得分:4)
我想在选择crteria满足时突出显示红色的行
你想要以红色亮相,但实际上是在MsgBox
使用此选项突出显示RED
cell.EntireRow.Interior.ColorIndex = 3