Interpret HTML in excel worksheet

  • Thread starter Thread starter dave.jaycock
  • Start date Start date
D

dave.jaycock

Hi,

I am grabbing some data from an html table using the following code:


-----------------------------------------------------------------------------
Dim url As String
Dim startTag As String
Dim endTag As String
Dim playerStats As Variant
Dim newPlayerArray As Variant
Dim counter As Single
'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
' player import
'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

url =
"http://www.sportsline.com/nhl/stats/playersort/regularseason/yearly/NHL/?&print_rows=9999"
startTag = "<div class=SLTables1>"
endTag = "</div>"


playerStats = gsGetString(url, startTag, endTag)

------------------------------------------------------------------------------

What I want to be able to do is take playerStats and PasteSpecial -
Unicode into Worksheets("test").Range("A1")

This will properly form a worksheet with all the statistics I am
looking for.

Any ideas would be appreciated.

Thanks
Dave
 
Dave

You can put that text into the clipboard using a DataObject, then use
PasteSpecial normally. The DataObject object is part of the Microsoft Forms
2.0 Library, so you'll need to set a reference if you haven't already
(Tools - References). Your code will look something like

Set objData as New DataObject

objData.SetText = playerStats
objData.PutInClipBoard

Sheet1.Range("A1").Select
Sheet1.PasteSpecial "Unicode Text"

See http://www.dicks-blog.com/archives/2005/02/23/html-in-cells-ii/ for
another example using DataObject.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top