deter_dangler
New Member
- Joined
- May 12, 2013
- Messages
- 4
I have a excel with column "A" containing non-formatted html data. To format this data, I am following the below steps:
1) Take the non-formatted html data from first cell and paste it on Internet explorer and paste the formatted text from html page to excel column "E" (HTML Text with tags to formatted text in an Excel cell - Stack Overflow)
2) From the excel column "E", read the data from first row to the final row and paste to the original cell preserving the formatting and i use the below code for that.
The problem is this code takes too much time to format the data, For 54 rows it is taking almost 10 minutes...
Is there any better solution for this?
Thanks in Advance
Note: I posted the same question on stackoverflow.com and waiting for answers..
1) Take the non-formatted html data from first cell and paste it on Internet explorer and paste the formatted text from html page to excel column "E" (HTML Text with tags to formatted text in an Excel cell - Stack Overflow)
2) From the excel column "E", read the data from first row to the final row and paste to the original cell preserving the formatting and i use the below code for that.
Code:
Sub ConcatenateRichText(Target As Range, Source As Range)
Dim Cell As Range
Dim i As Long
Dim c As Long
i = 1
With Target
.Clear
For Each Cell In Source
.Value = .Value & vbLf & Cell.Value
Next Cell
.Value = Trim(.Value)
End With
For Each Cell In Source
For c = 1 To Len(Cell.Value)
With Target.Characters(i, 1).Font
.Name = Cell.Characters(c, 1).Font.Name
.FontStyle = Cell.Characters(c, 1).Font.FontStyle
.Size = Cell.Characters(c, 1).Font.Size
.Strikethrough = Cell.Characters(c, 1).Font.Strikethrough
.Superscript = Cell.Characters(c, 1).Font.Superscript
.Subscript = Cell.Characters(c, 1).Font.Subscript
.OutlineFont = Cell.Characters(c, 1).Font.OutlineFont
.Shadow = Cell.Characters(c, 1).Font.Shadow
.Underline = Cell.Characters(c, 1).Font.Underline
.ColorIndex = Cell.Characters(c, 1).Font.ColorIndex
End With
i = i + 1
Next c
i = i + 1
Next Cell
End Sub
The problem is this code takes too much time to format the data, For 54 rows it is taking almost 10 minutes...
Is there any better solution for this?
Thanks in Advance
Note: I posted the same question on stackoverflow.com and waiting for answers..