Tagging formatting (cells with mixed formatting)

F

Fred Goldman

I need to tag all formatting (bold, itlaic, bold italic, superscript,
underline, etc) in all the cells throughout a worksheet. The way I am doing
it is looping through each cell of the UsedRange and then through each
character of each cell. I am wondering if there is a better/faster way to do
this. Any help would be much appreciated.

Here is what I have so far, I still have to add the Else If statements for
all the other formatting:

For Each myCell In rng.Cells
myBold = myCell.Font.Bold
If myBold = False Then
'do nothing
ElseIf myBold = True Then
'tag whole cell
myCell.Value2 = "<bold>" & myCell.Value2 & "</bold>"
Else
'we have a mixture so we must loop through each character in cell
myStr = ""
For iCtr = 1 To Len(myCell.Value)
If myCell.Characters(Start:=iCtr, Length:=1).Font.Bold = True Then
myStr = myStr & "<bold>" & Mid(myCell.Value, iCtr, 1) & "</bold>"
Else
myStr = myStr & Mid(myCell.Value, iCtr, 1)
End If
Next iCtr
myCell.Value = myStr
End If
Next myCell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top