RAJAQ
12/2/2016 - 12:28 PM

For Each-Next Loop Nested > Loop through a collection and objects. > Not surprisingly, you can create nested For Each-Next loops. The CountB

For Each-Next Loop Nested > Loop through a collection and objects. > Not surprisingly, you can create nested For Each-Next loops. The CountBold procedure loops through every cell in the used range on each worksheet in every open workbook and displays a count of the number of cells that are formatted as bold.

Sub CountBold()

Dim WBook As Workbook
Dim WSheet As Worksheet
Dim Cell As Range
Dim Cnt As Long

    For Each WBook In Workbooks
        For Each WSheet In WBook.Worksheets
            For Each Cell In WSheet.UsedRange
                If Cell.Font.Bold = True Then Cnt = Cnt + 1
            Next Cell
        Next WSheet
    Next WBook

MsgBox Cnt & " bold cells found"
End Sub