VBA高亮显示不是范围内日期的单元格
我试图突出显示范围内的非日期值。但是,我的代码不知怎么让我强调了空白单元格, 请问我应该换什么VBA高亮显示不是范围内日期的单元格,vba,date,highlight,Vba,Date,Highlight,我试图突出显示范围内的非日期值。但是,我的代码不知怎么让我强调了空白单元格, 请问我应该换什么 Sub colortest() Set MyPage = Range("B2:D6") For Each cell In MyPage Select Case cell.Value Case Not IsDate(cell) = False cell.Interior.Color = 65535 Case Is = "abc" cell.Inte
Sub colortest()
Set MyPage = Range("B2:D6")
For Each cell In MyPage
Select Case cell.Value
Case Not IsDate(cell) = False
cell.Interior.Color = 65535
Case Is = "abc"
cell.Interior.ColorIndex = 15
End Select
Next
End Sub
�
Excel屏幕截图
使用SpecialCells()
方法循环“常量”(即跳过空白)单元格
而如果MyPlage
范围内的数据有公式,只需将xlcelltypestants
更改为xlcelltypeformals
或
Option Explicit
Public Sub colortest()
Dim MyPlage As Range, currentCell As Range
Set MyPlage = Range("B2:D6")
For Each currentCell In MyPlage
If Not IsEmpty(currentCell) Then
Select Case IsDate(currentCell.Value)
Case 1
currentCell.Interior.Color = 65535
Case 0
currentCell.Interior.Color = 15
End Select
End If
Next currentCell
End Sub
Option Explicit
Public Sub colortest()
Dim MyPlage As Range, currentCell As Range
Set MyPlage = Range("B2:D6")
For Each currentCell In MyPlage
If Not IsEmpty(currentCell) Then
Select Case IsDate(currentCell.Value)
Case 1
currentCell.Interior.Color = 65535
Case 0
currentCell.Interior.Color = 15
End Select
End If
Next currentCell
End Sub