+ Reply to Thread
Results 1 to 14 of 14

Quicker External Data From Website into Excel single worksheet Help

  1. #1
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    61

    Thumbs up Quicker External Data From Website into Excel single worksheet Help

    Hello Everyone!!

    May someone help me out. I'm trying to get external data from a website by copying data and I don't want to copy it from the same webpage 51 times. I'm trying to get all the data from the online webpage by pasting it into one sheet in the excel worksheet. I'm using excel 2010 version.

    Here is the link of the site I'm trying to get the data from.

    http://sports.yahoo.com/nfl/stats/by...ld_category=DT

    What I want to do here is I want all the stats for DE position from year 2008 season to 2010 season and the timeframe is from week1-17. (17 weeks * 3 seasons data) = 51 times

    I don't want to keep hitting data->from web from the excel worksheet and punching in the site url to get the data 51 times and would like to save time.

    Anyone's help will be greatly appreciated!! Thanks!!
    Last edited by SimonLee; 08-28-2011 at 07:38 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Quicker External Data From Website into Excel single worksheet Help

    Please see the attachment.

    I've used a windows API function called inside a nested loop to get the data.
    Attached Files Attached Files
    Last edited by mrice; 08-18-2011 at 07:39 PM.

  3. #3
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Quicker External Data From Website into Excel single worksheet Help

    Wow great exactly what I needed. Thanks so much man!! Is this difficult?? Does it involved a lot of steps can you guide me through the steps I would like to try to create this same exact thing myself?

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Quicker External Data From Website into Excel single worksheet Help

    If you hit F11 and select the Module1 tab, you will see the code behind the button.

    To get a feel of how it is working, click anywhere inside the top subroutine (called Process) and press F8 on your keyboard. You will see a yellow highlighted line. Pressing F8 again will advance the code one line at a time. Use the mouse to hover over the variables (such as N, M, MyYear, MyWeek) to see how their values are changing as the code progresses. If you arrange the windows so that you can see the sheet in the background, you will see the data gradually build up.

    The code is effectively a loop within a loop. Everytime the inner loop executes, a call is made to the second subroutine (Called GetScore) which gets the data from the web by constructing a URL containing the year and week number.

    Hope this helps.

  5. #5
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Quicker External Data From Website into Excel single worksheet Help

    Thanks!! I see that the code you wrote is visual basic code ?? Any good site to understand visual basic?? Maybe if I understand the basics I would understand the code better.

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Quicker External Data From Website into Excel single worksheet Help

    This is VBA code which is a derivative of Visual Basic.

    In order to get started, I would suggest posting to the New Users part of this site to ask folk what they are currently finding useful in ascending the steepest part of the learning curve. The books that I learnt from will be very out of date.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Quicker External Data From Website into Excel single worksheet Help

    When using a Querytable you don't need an API call.
    If you put a querytable into sheet "web" the only code you need is:

    Please Login or Register  to view this content.


    You can use a querytable as often as you like, changing it's connection parameter. There's no need for every query to delete an existing querytable and to add a new one.
    Last edited by snb; 08-19-2011 at 08:04 AM.



  8. #8
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Quicker External Data From Website into Excel single worksheet Help

    where do i put this code at?? can i put it into a button where you can click??

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Quicker External Data From Website into Excel single worksheet Help

    Cfr. the attachment.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Quicker External Data From Website into Excel single worksheet Help

    Nice Thanks!! How do you build the button?? And how I check the code inside the button it won't let me right-click.

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Quicker External Data From Website into Excel single worksheet Help

    It is an Active-X control, not a formcontrol.
    Use the help in Excel.

  12. #12
    Registered User
    Join Date
    08-21-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    21

    Question Re: Quicker External Data From Website into Excel single worksheet Help

    Can this code be customized to download data from this website ??

    ttp://economictimes.indiatimes.com/infosys-ltd/quarterly/companyid-10960.cms

    ttp://economictimes.indiatimes.com/coal-india-ltd/quarterly/companyid-11822.cms

    I want to download data for few 100 companies .. i will make a list of company names and companyid's in two columns .. can a Macro pick these two fields generate an url and download the table into excel??

    Please help ..

    p.s. I have deleted the "h" from the start of link ..

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,007

    Re: Quicker External Data From Website into Excel single worksheet Help

    @Amar Thakkar:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    This is not the first time you have done this - please make sure it is the last.
    Everyone who confuses correlation and causation ends up dead.

  14. #14
    Registered User
    Join Date
    08-18-2011
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Quicker External Data From Website into Excel single worksheet Help

    the webquery_snb is copying stuff but not copying the correct data from the site that it is suppose to copy when clicking on start retrieving data dialog box. how to see the code in the dialog box??

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1