我在excel中收到了html文本,我只想从中提取一些文本。
我在单元格A1中有以下文字:
<b>From:</b></p> </td>
<td width=760 colspan=10 valign=bottom
style='width:380.0pt;padding:0in 0in 0in 0in; height:9.05pt'>
<p class=MsoNormal><a href="mailto:[email protected]">LastName, First</a></p>
</td> </tr>
我想提取“[email protected]”和“LastName,First”,并将它们分别放入单元格B1和C1中。我需要通过多个单元格循环这个,所以我需要考虑字符串的长度不同。
对于更多的上下文,这个以前的thread为我想要做的事情提供了一个良好的基础,但我坚持如何继续,因为我拉的长度和内容不同的字符串。
也许是这样的。谨防引号(“),我的HTML变量代码没有考虑到它!在HTML代码字符串分隔符中查找始终相同
Dim HTMLarray1() As String
Dim HTMLarray2() As String
Dim HTML As String
HTML = "<b>From:</b></p></td><td width=760 colspan=10" _
& "valign=bottom style='width:380.0pt;padding:0in 0in 0in 0in;" _
& "height:9.05pt'><p class=MsoNormal>" _
& "<a href="mailto:[email protected]">LastName, First" _
& "</a></p></td></tr>"
HTMLarray1 = Split(HTML, "<a href="mailto:")
HTMLarray1 = Split(HTMLarray1(1), "">")
HTMLarray2 = Split(HTMLarray1(1), "</a>")
Dim email As String
Dim name As String
email = HTMLarray1(0)
name = HTMLarray2(0)