Hi!
I inserted my code and added some comment. I hope that somebody can find the mistake.
Can you spot the mistake? (Value error)
Thank you very much
I inserted my code and added some comment. I hope that somebody can find the mistake.
Code:
Function CountBold(WorkRng As Range)
Dim i, xcount As Integer
For i = 1 To Len(WorkRng)
If WorkRng.Characters(i, 1).Font.Bold = True Then
If WorkRng.Characters(1, 1).Fold.Bold = True Then
xcount = 1 ' if first character is bold then we give the value of 1 to xcount ([B]You[/B] ate an [B]apple yesterday.[/B] -->1)
End If
If WorkRng.Characters(i - 1, 1) = " " Then 'for every other word in cell we count the cases when there is a bold
'letter and a space before it --> ([B]You[/B] ate an [B][COLOR=#ff0000]a[/COLOR]pple [COLOR=#ff0000]y[/COLOR]esterday.[/B] -->1 for "you" and +2 = 3 words
xcount = xcount + 1
End If
End If
Next i
CountBold = xcount
End Function
Can you spot the mistake? (Value error)
Thank you very much
Last edited: