Custom Search

Tutorial:

SQL
VBA

Home >> VBA Macro's >> Find Negative

Find Negative


Suppose you have 2000 entries in worksheet and you are interested to find out negative value under the particular column. By manually it may be difficult to locate all such entries. So we can use the following code to highlight those entries.

Private Sub FindNegative_Click()
Dim findneg As Range
Dim count As Integer

Range("a1").Activate

For Each findneg In Range(ActiveCell, ActiveCell.End(xlDown)).Cells
   If findneg.Value < 0 Then
      count = count + 1
      findneg.Font.Color = vbRed
   End If
Next findneg

MsgBox "There are" & count & " Negative values", vbCritical

End Sub