Jak
Well-known Member
- Joined
- Apr 5, 2002
- Messages
- 833
Hi, I am highlighting cells with values that contain non numeric values or the numeric values that are greater or less than 10 digits in the column. The code does this. However, the numeric check does not stop at row 2. It picks up the header row which is text and highlights it. I can get around this by changing .End(xlUp).Row to .End(xlDown).Row in the code but it adds time to the code execution. Any pointers on getting the code to stop at row 2 would be welcomed.
VBA Code:
Dim myRange As Range, lr As Long
lr = Cells(Rows.Count, "H").End(xlUp).Row
Set myRange = Range("H2:H" & lr)
For Each cell In myRange
If Len(Trim(cell)) > 0 Then
If IsNumeric(cell) And Len(cell) <> 10 Then cell.Interior.ColorIndex = 6
If Not IsNumeric(cell) Then cell.Interior.ColorIndex = 6
End If
Next cell