Run Time Error 1004 - WebQuery

marihouse

Board Regular
Joined
Jan 14, 2004
Messages
84
I have a webquery that works.
I have it cycle through about 50 names and pull the information from the web for a range of dates for each name and import the data.

My problem is if I pull the data for all 50 names for August 1st thru September 30th, it works because there is a webpage of data for everybody within that timeframe. But, if I just pull data for say September 27th thru September 30th only 35 of them might actually have the web data page for that date range. So as it cycles through the names and gets to one that doesn't have data for that date range (the date range is part of the webpage address) then I get the runtime error 1004 and the page doesn't exist.

How can I tell it to skip over that page instead of the macro stopping with the error? I have no way of knowing which names have data or not for a specific date range and I am wanting to add to my current data and not wanting to do the entire set of available dates each time, because my lookups and formulas that are depending on the data makes it take too long to calculate once I have retrieved it. I just need the most recent data each time.

Thanks.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
If this is a VBA webquery (or more accurately a VBA QueryTable object) trap possible errors with 'On Error' before the QueryTable .Refresh and check for Err.Number = 1004 and ignore it or tell the user or otherwise log the outcome.
 
Upvote 0
Thank you. That sounds like exactly what I need to do. Could you tell me what the code is?
I haven't seen that before. Thanks!
 
Upvote 0

Forum statistics

Threads
1,216,434
Messages
6,130,611
Members
449,584
Latest member
c_clark

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