2
這是我的VBA代碼:VB代碼以刪除HTML代碼總是崩潰Excel的〜40K的數據集
Sub RemoveTags()
Dim r As Range
Selection.NumberFormat = "@" 'set cells to text numberformat
With CreateObject("vbscript.regexp")
.Pattern = "\<.*?\>"
.Global = True
For Each r In Selection
r.Value = .Replace(r.Value, "")
Next r
End With
End Sub
它從我的細胞,但崩潰刪除所有的標記語言,當我運行它〜40K的記錄。我的代碼有問題嗎?或者我應該更改Excel設置?
[不使用正則表達式來解析HTML(或對其進行處理)](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self -contained標籤/ 1732454#1732454)。將HTML加載到「HTMLFile」對象並返回文檔對象的'.innerText'可能會更好。 –
嘗試'Selection.Replace「<*>」,「」'改爲 – Slai