[英]Excel How I can delete everything in a cell except the content within specific html tag?
我的Excel工作表有700多行,在第二列中,我使用html代碼描述了產品。 我需要提取始終在...中的特定值。
<div class="something">
<p><strong>Content to remove</strong></p>
<h1>Content to remove</h1>
<p>Content to remove</p>
<h1 class="modelaut">CONTENT TO KEEP</h1>
<p>Content to remove</p>...
</div>
“要保留的內容”在每行中的位置不同,但始終在具有特定class =“ modelaut”的H1標簽中
謝謝你的幫助 :)
該守則就是這樣。
Sub transString()
Dim vDB, vSplit1, vSplit2
Dim rngDB As Range, i As Long
Set rngDB = Range("b1", Range("b" & Rows.Count).End(xlUp))
vDB = rngDB
For i = 1 To UBound(vDB, 1)
vSplit1 = Split(vDB(i, 1), "<h1 class=" & Chr(34) & "modelaut" & Chr(34) & ">")
vSplit2 = Split(vSplit1(1), "</h1>")
vDB(i, 1) = "<h1 class=" & Chr(34) & "modelaut" & Chr(34) & ">" & vSplit2(0) & "</h1>"
Next i
rngDB = vDB
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.