+ Reply to Thread
Results 1 to 3 of 3

VBA webquery 'data refreshing' error 1004 after first few loops

  1. #1
    Registered User
    Join Date
    10-16-2011
    Location
    Surrey, England
    MS-Off Ver
    Excel 2003
    Posts
    1

    VBA webquery 'data refreshing' error 1004 after first few loops

    I'm new to macros and I'm trying to automate the following task: I have a long list of medical writers and I want to plug their names into the search box at www.evidence.nhs.uk/ and copy the list of medical papers each one has witten and put it in a spreadsheet (see attached).

    I've set up the code to loop through each row and send a webquery for each name - it then tidies up the results (which for some reason are inserted in different cells all down the column), numbers them and stick them in one cell.

    When I run the macro it works fine for the first few names then gives up and I get a 1004 error 'this operation cannot be done because the data is refreshing in the background.' Sometimes 'External Data' plus a number appears in the cell where the query data should go.

    I've not much idea how webqueries work so I'm stuck...here is the query code:

    Please Login or Register  to view this content.
    I've tried making BackgroundQuery or Refresh BackgroundQuery = False, tried to delete queries after each loop...in fact I've wasted a weekend trying to save myself work next week...!
    Attached Files Attached Files

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: VBA webquery 'data refreshing' error 1004 after first few loops

    The first question I have to ask is about
    Please Login or Register  to view this content.
    Where is the selection supposed to be?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: VBA webquery 'data refreshing' error 1004 after first few loops

    I commented out two lines, the save password and save data lines.
    Please Login or Register  to view this content.
    That seemed to have taken care of the errors but it looks like your code is copying all of the contents of the webpage.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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