如何在search时select一些东西

当select标准满足时,我想突出显示红色的行,但是我发现在search程序的整个过程中没有select任何单元格,我该怎么办?

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 

我想在select标准符合时突出显示红色的行

你想用红色突出显示,但实际上是在MsgBox显示单元格

使用这个来突出显示RED的行

 cell.EntireRow.Interior.ColorIndex = 3