Article ID: 148356
Article Last Modified on 10/11/2006
Sub Check_Values_1()
Dim CurCell As Object
For Each CurCell In Selection
If CurCell.Value = 5 Then CurCell.Interior.ColorIndex = 6
Next
End Sub
The following example loops through a specified range instead of the
selected range and sets any cells that equal 10 to 20.
Sub Check_Values_2()
Dim CurCell As Object
For Each CurCell In Range("A1:A10")
If CurCell.Value = 10 Then CurCell.Value = 21
Next
End Sub
For additional information on looping, please see the following
article in the Microsoft Knowledge Base:
141762 XL: How to Use Looping Structures in Visual Basic for Applications
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: 5.00a 5.00c xl97 8.00 xl howto loop XL
Keywords: kbdtacode kbhowto kbprogramming KB148356