VBA to change cell to each value in range, copy and paste results

DFSGolfMetrics

New Member
Joined
Sep 18, 2015
Messages
4
Thank you all in advance, I have a worksheet that includes a dynamic web query. There are 3 inputs: a year, a location ID, and a statistic ID that are all part of their own data validation range. Currently, every time I change one of those inputs the web query updates. What I'd like to do is run a macro that updates the 3 inputs to all possible values and after each change copy and paste the web query results to a new sheet (preferably named based on cell in query data).

The year input cell is E2, from data validation range A2:A12
The location ID cell is C9, from data validation range B14:B63
The statistic ID cell is C8, from data validation range B65:B633

The range to copy and paste to a new sheet is G:P and can be pasted in new sheet at A1.

Thank you!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
What does the web query update, a range in a sheet? There are are 312,950 possible combinations for your validation ranges. How will this impact your output destination(s).
 
Upvote 0
The query updates with data from a web page. Those 3 inputs are part of the URL. If the data is too large we could probably start small with only a few of the statistic IDs to test. It automatically refreshes with each input change so after that change I'd like to put the data in a new tab. It doesn't necessarily need to be a brand new tab for each iteration, as long as the data is logged before moving to the next input variation. Thank you for your response.
 
Upvote 0
Still confused.

When you change an input, how does the web query update? Is the web query linked to a cell?

For the combination {A2,B14,B65}, does a sheet get created and named based on the query data?

For the next combination {A3,B14,B65} does a new sheet get created and so on?

So, the way you have it working now, is a new sheet created each time you change an input?
 
Upvote 0
Right now the three cells: E9, C8, and C9 are drop down lists with a data validation of those ranges. When the dropdown is selected the web query automatically refreshes. There is no new sheet created, the query data is pasted in current sheet.
 
Upvote 0
Where does the second combination get pasted, right below the first? Does it skip a line? There's only a million rows. How many rows do you need for 300K iterations? Am I missing something?
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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