Sub Hello()
Dim lRow As Integer
Dim MR As Variant
Dim Cell As Variant
lRow = Range("A" & Rows.Count).End(xlUp).Row
Set MR = Range("A2:A" & lRow)
For Each Cell In MR
If Cell.Value = Format(Date, "dd-mmm-yy") Then Cell.Interior.ColorIndex = 10
Next
End Sub
我试图在整个A栏中找到这种格式为“10-Jan-16”的任何日期值,但此代码无效,
答案 0 :(得分:0)
Option Explicit
Sub ColourCells()
Dim lRow As Integer
Do While Range("A" & lRow + 1).Value <> ""
lRow = lRow + 1
If Range("A" & lRow).Text = Format(Range("A" & lRow).Text, "dd-MMM-yy") Then
Range("A" & lRow).Cells.Interior.ColorIndex = 10
End If
Loop
End Sub
检查&#34;文字&#34;属性将为您提供您在Excel中看到的内容,这与在&#34; Value&#34;中所拥有的内容不同。属性。