Extracting data from website using VBA


"Excel VBA Help"

 

Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Excel Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Excel Forum Members Post questions in this forum if they are related to using Microsoft Excel, this includes Worksheet Functions, Excel VBA Programming, Simple Macro Code & Charting, Excel formula etc.

New Reply
Thread Tools Rate Thread Display Modes
  #1  
Unread 27th March 2012, 17:57
Cutter's Avatar
Cutter Cutter is offline
Junior Member
MS Office Version: Excel 2010
MS Office Skill Level: Can use Formulae
 
Join Date: Mar 2012
Location: Ontario, Canada
Age: 62
Posts: 7
Posts Per Day: 0.01
My Top Tip Count: 0
Thanks to others: 3
Thanked 0 Times in 0 Posts
Reputation: 10 (3) Cutter is on a distinguished road
Canada
Default Extracting data from website using VBA
     Excel: VBA   


Hi Folks
My second attempt to start this thread. Last night I kept receiving message to remove links even though there weren't any.
On to the problem - I attempted to follow the instructions given in a YouTube clip demonstrating how to extract specific data from a web site. The demo was for a site that provides the city, county and state when a zip code is inserted. Although I have no interest in that example I was hoping to be able to adapt the method for other sites. But of course the macro failed and I can't resolve it. VBA is not my forte!
I can't upload the file (forum rules re my noobiness here) nor can I provide the link to the clip (same forum rule). I'm hoping someone can spot an error in the code below:

VBA CODE:
Option Explicit 
 
Private Sub Worksheet_Change(ByVal Target As Range) 
    If Target.Row = Range("Zip_Code").Row And Target.Column = Range("Zip_Code").Column Then 
        Dim IE As New InternetExplorer 
         'IE.Visible = True
        IE.navigate "http://quickfacts.census.gov/cgi-bin/qfd/lookup?place=" & Range("Zip_Code").Value 
        Do 
            DoEvents 
        Loop Until IE.readyState = READYSTATE_COMPLETE 
        Dim doc As HTMLDocument 
        Set doc = IE.document 
        Dim sdd As String 
        sdd = Trim(doc.getElementsByTagName("dd")(1).innerText) 
        IE.Quit 
         'MsgBox sdd
        Dim add As Variant 
        add = Split(sdd, ", ") 
        Range("County").Value = add(1) 
        Range("City").Value = add(0) 
        Range("State").Value = add(2) 
    End If 
End Sub 

The macro throws this error on the highlighted line:
Run-time error '91':
Object variable or With block variable not set

Thanks for looking
Bill

The Code Cage Advertisment
Advertisement
  #2  
Unread 27th March 2012, 18:01
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
Administrator
MS Office Version: MS Office 97 - 2013
MS Office Skill Level: Can use most of MS Office
 
Join Date: Aug 2008
Location: Manchester, England
Age: 49
Posts: 11,632
Posts Per Day: 5.34
My Top Tip Count: 11
Thanks to others: 38
Thanked 416 Times in 405 Posts
Reputation: 6334 (185) Simon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond repute
11 Top Tips
Wales
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.





__________________
Regards,
Simon Lloyd
Microsoft Office Help

Want to say thanks? then hit this How to say thanks! button in any post you want to thank
If you find one of my posts helpful then hit this one Helpful Answer in the post that helped most!



The Following User Says Thank You to Simon Lloyd For This Useful Post:
Cutter (27th March 2012)
  #3  
Unread 27th March 2012, 18:05
norie's Avatar
norie norie is offline
Solution Centre Professional
MS Office Version: MS Office 2000/2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Aug 2009
Location: Yaren
Posts: 226
Posts Per Day: 0.13
My Top Tip Count: 0
Thanks to others: 0
Thanked 20 Times in 20 Posts
Reputation: 339 (10) norie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the rough
Mexico
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






The Code Cage Advertisment
Advertisement
  #4  
Unread 27th March 2012, 18:21
Cutter's Avatar
Cutter Cutter is offline
Junior Member
MS Office Version: Excel 2010
MS Office Skill Level: Can use Formulae
 
Join Date: Mar 2012
Location: Ontario, Canada
Age: 62
Posts: 7
Posts Per Day: 0.01
My Top Tip Count: 0
Thanks to others: 3
Thanked 0 Times in 0 Posts
Reputation: 10 (3) Cutter is on a distinguished road
Canada
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.





Attached Files To view attachments in this forum your post count must be 2 or greater. You currently have 0 posts.

  #5  
Unread 27th March 2012, 18:35
norie's Avatar
norie norie is offline
Solution Centre Professional
MS Office Version: MS Office 2000/2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Aug 2009
Location: Yaren
Posts: 226
Posts Per Day: 0.13
My Top Tip Count: 0
Thanks to others: 0
Thanked 20 Times in 20 Posts
Reputation: 339 (10) norie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the rough
Mexico
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






  #6  
Unread 27th March 2012, 19:39
Cutter's Avatar
Cutter Cutter is offline
Junior Member
MS Office Version: Excel 2010
MS Office Skill Level: Can use Formulae
 
Join Date: Mar 2012
Location: Ontario, Canada
Age: 62
Posts: 7
Posts Per Day: 0.01
My Top Tip Count: 0
Thanks to others: 3
Thanked 0 Times in 0 Posts
Reputation: 10 (3) Cutter is on a distinguished road
Canada
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






The Code Cage Advertisment
Advertisement
  #7  
Unread 27th March 2012, 20:07
norie's Avatar
norie norie is offline
Solution Centre Professional
MS Office Version: MS Office 2000/2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Aug 2009
Location: Yaren
Posts: 226
Posts Per Day: 0.13
My Top Tip Count: 0
Thanks to others: 0
Thanked 20 Times in 20 Posts
Reputation: 339 (10) norie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the rough
Mexico
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






Reply & Quote Reply


1 members found this post helpful.
The Following User Says Thank You to norie For This Useful Post:
Cutter (27th March 2012)
  #8  
Unread 27th March 2012, 20:33
snb's Avatar
snb snb is offline
Forum VIP
MS Office Version: > Office 97
MS Office Skill Level: Interested
 
Join Date: Feb 2011
Location: Europe
Posts: 1,200
Posts Per Day: 0.96
My Top Tip Count: 0
Thanks to others: 0
Thanked 268 Times in 262 Posts
Reputation: 4505 (61) snb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond repute
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






Reply & Quote Reply


1 members found this post helpful.
The Following User Says Thank You to snb For This Useful Post:
Cutter (27th March 2012)
  #9  
Unread 27th March 2012, 21:28
Cutter's Avatar
Cutter Cutter is offline
Junior Member
MS Office Version: Excel 2010
MS Office Skill Level: Can use Formulae
 
Join Date: Mar 2012
Location: Ontario, Canada
Age: 62
Posts: 7
Posts Per Day: 0.01
My Top Tip Count: 0
Thanks to others: 3
Thanked 0 Times in 0 Posts
Reputation: 10 (3) Cutter is on a distinguished road
Canada
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






The Code Cage Advertisment
Advertisement
  #10  
Unread 27th March 2012, 21:46
norie's Avatar
norie norie is offline
Solution Centre Professional
MS Office Version: MS Office 2000/2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Aug 2009
Location: Yaren
Posts: 226
Posts Per Day: 0.13
My Top Tip Count: 0
Thanks to others: 0
Thanked 20 Times in 20 Posts
Reputation: 339 (10) norie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the roughnorie is a jewel in the rough
Mexico
Default Re: Extracting data from website using VBA

------ Register to get rid of these "In Post" ads! ------


Warning

Warning



Sorry but you need to register for FREE to see the rest of these posts. Please click HERE to register.

We only allow guests to see the first post of every thread to keep valuable resources for our members.






The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!

New Reply
The Code Cage at Facebookhe Code Cage at Twitter


Tags
data, extracting, vba, website

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 19:15.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University