[Excel-VBA] Zählen, wenn Fett/Kursiv ua.

Gepostet am: Nov 29, 2015 10:35:59 AM

Kürzlich stand ich vor dem Problem, nur die Zellen zählen zu wollen, die eine bestimmte Formatierung aufweisen.

Anbei die Funktionen:

CountBold

Public Function CountBold(myRange As Range) As IntegerDim i As IntegerDim j As IntegerDim BoldCounter As IntegerWith myRange     For i = 1 To myRange.Rows.Count         For j = 1 To myRange.Columns.Count             If .Cells(i, j).Font.Bold = True And .Cells(i, j).Value <> "" Then                 BoldCounter = BoldCounter + 1             End If         Next j     Next i End With CountBold = BoldCounter End Function

CountItalic

Public Function CountItalic(myRange As Range) As IntegerDim i As IntegerDim j As IntegerDim ItalicCounter As IntegerWith myRange     For i = 1 To myRange.Rows.Count         For j = 1 To myRange.Columns.Count             If .Cells(i, j).Font.Italic = True And .Cells(i, j).Value <> "" Then                 ItalicCounter = ItalicCounter + 1             End If         Next j     Next i End With CountItalic = ItalicCounter End Function

CountItalicBold

Public Function CountItalicBold(myRange As Range) As IntegerDim i As IntegerDim j As IntegerDim ItalicBoldCounter As IntegerWith myRange     For i = 1 To myRange.Rows.Count         For j = 1 To myRange.Columns.Count             If .Cells(i, j).Font.Italic = True And .Cells(i, j).Font.Bold = True And .Cells(i, j).Value <> "" Then                 ItalicBoldCounter = ItalicBoldCounter + 1             End If         Next j     Next i End With CountItalicBold = ItalicBoldCounter End Function