From: Fred Goldman on 25 Apr 2010 10:44
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
ElseIf myBold = True Then
'tag whole cell
myCell.Value2 = "<bold>" & myCell.Value2 & "</bold>"
'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>"
myStr = myStr & Mid(myCell.Value, iCtr, 1)
myCell.Value = myStr
Prev: Formula ?
Next: Delete contents of cells in a range based on value of a cell