Good morning all!
I am stuck on writing on some VBA code. Thus far my experience with writing VBA code in Excel has been simple copying, pasting, sorting, etc - stuff that I can record a macro for and just copy the code over.
My current need way exceeds my experience and expertise and I need some help.
I have a VBA string variable which contains multiple blocks of HTML code from a website source. From this VBA string, I need to parse specific data that is located between tags in the HTML source code. Here is an example of the HTML source code from which I need to parse data:
<p class="row">
<span class="ih" id="images:ABC123.jpg"> </span>
<span class="itemdate"> Jul 2</span>
<span class="itemsep"> - </span>
<a href="http://www.abc.com">ABC Heating and Cooling</a>
<span class="itemsep"> - </span>
<span class="itemph"></span>
<span class="itempp"> $800</span>
<span class="itempn"><font size="-1"> (ABC)</font></span>
<span class="itemcg" title="gms"> <small class="gc"><a href="/gms/">ABC Get Your Free Quote</a></small></span>
<span class="itempx"> <span class="p"> pic</span></span>
<br class="c">
</p>
If you consider the above HTML source code as a "block" of code, then the VBA string variable contains multiple "blocks" of this code. For the example code above, I need to parse out the following data only (keeping in mind that this process will have to be repeated until all of the "blocks" have been processed through):
images:ABC123.jpg
Jul 2
-
http://www.abc.com
ABC Heating and Cooling
-
$800
(ABC)
ABC Get Your Free Quote
Everything that is highlighted in this picture is what I need parsed out:
Parsed.jpg
Then I would like to pass the parsed data out to a variant array which could later be used to paste into an Excel worksheet. I am thinking the array would be in the following format with the top row of the array being headers (using the same example above):
SampleArray.jpg
After finishing one of these "blocks", the program has to go to the next "block" and repeat the parsing process (and making a new row in the array for that block of data) until it has gone through all of the "blocks" in the VBA string. I am guessing that some kind of loop would be needed for this.
My best guess for the parsing is to use Regex???
Thank you all for taking a look at this, I appreciate the help!
Bookmarks