Free Microsoft Excel Training Videos

For Each Next Loop

The true way to perform automatic calculations is to use the looping process.
'For each... next' loop in Excel is used here to perform formatting based on criteria: Another easy way to loop through a range in Microsoft Excel is to use a For Each...Next loop with the collection of cells specified in the Range property. The macro automatically sets an object variable for the next cell each time the loop runs. The following Microsoft Excel training video describes a procedure that loops through the range B2:B10, setting to 'pink' all values greater than or equal to 9000.Another instance of conditional formatting!
Macro code:
Sub ColorMyCells()
For Each c in Worksheets("Sheet1").Range("B2:B10").Cells
If c.Value>=9000 Then c.Font.ColorIndex=7
End Sub

Further Reading

For Each Next loop macro