VBA MACRO 4 ISNUMBER OPERATION

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
 
B

Bob Phillips

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)
 
G

Guest

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?
 
B

Bob Phillips

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)
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top