Mở VBA trong Excel [Alt + F11], nhấp vào tên dự án [tên bảng tính] trong trình khám phá dự án ở bên phải. Chèn -> Mô-đun mới. Dán chức năng do người dùng xác định bên dưới vào cửa sổ mô-đun. Lưu thành. XLSM cho phép Macro
nhập hàm '=StripHTML[A2]' giả sử dữ liệu của bạn nằm trong ô A2. Bạn cũng có thể tải xuống một ví dụ hoạt động tại đây
http. //jfrancisconsulting. com/how-to-strip-html-tags-in-excel/
Function StripHTML[cell As Range] As String
Dim RegEx As Object
Set RegEx = CreateObject["vbscript.regexp"]
Dim sInput As String
Dim sOut As String
sInput = cell.Text
sInput = Replace[sInput, "\x0D\x0A", Chr[10]]
sInput = Replace[sInput, "\x00", Chr[10]]
'replace HTML breaks and end of paragraphs with line breaks
sInput = Replace[sInput, "", Chr[10] & Chr[10]]
sInput = Replace[sInput, "
", Chr[10]]
'replace bullets with dashes
sInput = Replace[sInput, "
", "-"]
'add back all of the special characters
sInput = Replace[sInput, "–", "–"]
sInput = Replace[sInput, "—", "—"]
sInput = Replace[sInput, "¡", "¡"]
sInput = Replace[sInput, "¿", "¿"]
sInput = Replace[sInput, """, ""]
sInput = Replace[sInput, "“", ""]
sInput = Replace[sInput, "”", ""]
sInput = Replace[sInput, "", "'"]
sInput = Replace[sInput, "‘", "'"]
sInput = Replace[sInput, "’", "’"]
sInput = Replace[sInput, "«", "«"]
sInput = Replace[sInput, "»", "»"]
sInput = Replace[sInput, " ", " "]
sInput = Replace[sInput, "&", "&"]
sInput = Replace[sInput, "¢", "¢"]
sInput = Replace[sInput, "©", "©"]
sInput = Replace[sInput, "÷", "÷"]
sInput = Replace[sInput, ">", ">"]
sInput = Replace[sInput, "