excel - formatting html data and writing back to same cell - performance issue

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.


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..
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top