Loading

Wednesday, February 18, 2009

Looping through a range

The following microsoft excel VBA macro example demonstrates how to loop through all the cells in a range. This example uses the For Each...Next statement to search the word "Microsoft Excel VBA" in a range and changes its font style to bold. In this case, the range is from A1 to E5.

Sub ChangeFontStyle()
Dim Cell As Range

For Each Cell In Range("A1:E5")
If LCase(Cell.Value) = "microsoft excel vba" Then
Cell.Font.Bold = True
End If
Next Cell
End Sub

SHARE TWEET

Thank you for reading this article Looping through a range With URL https://x-tutorials.blogspot.com/2009/02/looping-through-range.html. Also a time to read the other articles.

0 comments:

Write your comment for this article Looping through a range above!