vba按分科和班级划分

时间:2016-09-21 19:39:44

标签: excel vba excel-vba

形成这个html废料,我只想得到" NO IPLAN PRODUCT - 1"这只是最后一次在columno4下,

<div class="row02"> <div class="column01"> <span class="outputLabel">Originator:</span> <span class="outputText" id="originator_sessionheader">DORIS M MORRIS - SUBSCRIBER/RECIPIENT</span> </div> <div class="column02"> <span class="outputLabel">Tax ID:</span><span class="outputText"></span> </div> <div class="column03"> <span class="outputLabel" style="vertical-align: 2px;">PBB <!-- IE11 remediation changes --> <img class='imgLink' onclick="openKMWindow('https://svckm.uhc.com/eAgent/iq/ISET/gateway.jsp?create=kb%3AUHG&report()=p[prem_based_ben]');return false;" src="/chap/images/qm_drkBlue.gif" width="13" height="13" alt="PBB KM" title="PBB KM"/> </span> <span class="outputText" style="vertical-align: 2px;">:N</span> </div> <div class="column04"> <span class="outputLabel style="vertical-align: 2px;">iPlan <!-- IE11 remediation changes --> <img class='imgLink' onclick="openKMWindow('https://svckm.uhc.com/eAgent/iq/ISET/gateway.jsp?create=kb%3AUHG&view()=c[i_iplan_ind]');return false;" src="/chap/images/qm_drkBlue.gif" width="13" height="13" alt="IPLAN KM" title="IPLAN KM"/> </span> <span class="outputText" style="vertical-align: 2px;cursor:pointer" title="NO IPLAN PRODUCT">:1</span>

我尝试了多个vba代码,但没有得到任何解决方案,

1 个答案:

答案 0 :(得分:0)

不太确定你要问的是什么,但是从NO IPLAN标记位获得值1,你可以使用我最近因为XML解析而开始用作函数的基本文本字符串操作问题:

Sub ho()

Dim str As String
Dim schSTR As String
Dim t1 As Integer
Dim t2 As Integer
Dim t3 As Integer

str = *this is where your HTML scrape would be assigned*
schSTR = "NO IPLAN PRODUCT"">:"

If InStr(1, str, schSTR, vbBinaryCompare) Then
  t1 = InStr(1, str, schSTR, vbBinaryCompare) + Len(schSTR)
  t2 = InStr(t1, str, "<", vbBinaryCompare)
  t3 = t2 - t1
  result = Mid(str, t1, t3)
  MsgBox result
End If
End Sub

这将为您提供&#34; 1。&#34;

的消息

如果我已正确理解你的requeset,这将适用于任何包含schSTR变量的html页面/ scrape(在这种情况下&#34; NO IPLAN PRODUCT&#34;&gt;:&#34;