VBA to extract part of HTML code

smide

Board Regular
Joined
Dec 20, 2015
Messages
164
Office Version
  1. 2016
Platform
  1. Windows
Hello.


In cell A1 I'm receiving Customer names an their home town in form of huge HTML code.
I need to extract Customer names in column A (A3:A600) and their home towns in column B (B3:B600).

Part of HTML code for names is always the same:
HTML:
<div class="customName--1gBeC">J. Jones</div>

Part of code for towns is also always the same:
HTML:
<td class="search-results-table-column-town ">Sydney</td>


Basically I need to extract somehow only part between
HTML:
1gBeC">
and
HTML:
</div>
for Name and part between
HTML:
column-town ">
and
HTML:
</td>
for Town.


I'm using excel 2007.

example.

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]HTML code[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]J. Jones[/TD]
[TD="align: center"]Sydney[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]C. Duncan[/TD]
[TD="align: center"]Toronto[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]M. Weber[/TD]
[TD="align: center"]München[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]....[/TD]
[TD="align: center"]....[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,632
Messages
6,173,472
Members
452,516
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top