VBA MACRO 4 ISNUMBER OPERATION

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear fellows,

I want a simple macro (Not Conditional Formatting), to detect cells in
column C:C that are either NOT numbers OR are below 5 and highlight them with
Blue Color background and Bold Red color fonts.

Regards
 
Public Sub ProcessData()
Const TEST_COLUMN As String = "C" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow 'iLastRow to 1 Step -1
If .Cells(i, TEST_COLUMN).Value <> "" And _
(Not IsNumeric(.Cells(i, TEST_COLUMN).Value) Or _
Cells(i, TEST_COLUMN).Value < 5) Then
With .Cells(i, TEST_COLUMN)
.Interior.ColorIndex = 5
.Font.ColorIndex = 3
.Font.Bold = True
End With
End If
Next i

End With

End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Sorry Bob but code is not working!

Can you simply write a code to highlight the cell (C5) to Blue if its value
is not numeric and similarly...

highlight the cell (C6) to Blue if its value is numeric but below < 5?
 
I responded to another question from you on that using conditional
formatting.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Sorry BOB but your answer to the other question i.e. using feature of
Conditional Formatting was not useful. I simply want to know the structure of
a VBA CODE in this regard. Please let me know if u can.

Thanx
 
Back
Top