フォーマットされていないhtmlデータを含む列「A」を持つExcelがあります。このデータをフォーマットするには、次の手順に従います。
1)最初のセルからフォーマットされていないhtmlデータを取得し、Internet Explorerに貼り付け、フォーマットされたテキストをhtmlページからExcel列「E」に貼り付けます (Excelセルのフォーマットされたテキストへのタグ付きHTMLテキスト)
2) Excel の列 "E" から、各行から最終行までのデータを読み取り、元のセルに貼り付けて書式を保持し、そのために以下のコードを使用します。
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
問題は、このコードがデータをフォーマットするのに時間がかかりすぎることです.54行の場合、ほぼ10分かかります...
これに対するより良い解決策はありますか?
完全なコードのリンクは次のとおりですhttp://pastebin.com/fZbQPYbg
前もって感謝します
注: mrexcel.comに同じ質問を投稿しました。回答があればここで更新します。