I am trying to search each cell individually in a named range and find each cell that has italic font. If the font is italic then I would like to add that cell's number to a variable so I can get a total.
Any help is much appreciated.
Justin
You are looking for the .Font.Italic
property. Test the following. Modify accordingly.
Sub AddItalicizedNums()
Dim TargetRng As Range, Cell As Range
Dim SumOfItalics
Set TargetRng = Range("OneToTwenty")
SumOfItalics = 0
For Each Cell In TargetRng
If Cell.Font.Italic = True Then
SumOfItalics = SumOfItalics + Cell.Value
End If
Next Cell
MsgBox SumOfItalics
End Sub
Screenshot:
My named range is OneToTwenty
and I italicized (and boldfaced) all even numbers in it. The sum is showing correctly, as shown in the message box.
Let us know if this helps.