我想在符合选择条件时突出显示红色行,但我发现在整个搜索过程中程序没有选择任何单元格,我该怎么办?
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
最佳答案
I want to highlight the row in red when the selection crteria met
您想以红色突出显示,但实际上是在 MsgBox
中显示单元格
使用它来突出显示RED
中的行
cell.EntireRow.Interior.ColorIndex = 3
关于excel - 搜索时如何选择某些内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20510568/