Web Query/Cell Reference

  • Thread starter Thread starter hawkeyes2002
  • Start date Start date
H

hawkeyes2002

I've got a spreadsheet that contains a number of different web querie
for MLB stats from espn.com. I'm trying to create a macro that wil
refresh the data for these queries. Here's a visual of what it look
like:

TEAM NAME

stats from web query
stats from web query
stats from web query


TEAM NAME

stats from web query
stats from web query
stats from web query

The data from the web queries do not always stay the same size. What
want the macro to do is this:

find "TEAM NAME", select the cell that is two cells below "TEAM NAME"
and refresh the data from the web query.

I'm having trouble figuring out the "select the cell that is two cell
below 'TEAM NAME' " part. Any help would be appreciated
 
hawkeyes2002

How many web queries do you have on your sheet? Two? Do you want to find a
specific team name and only update the stats for that team? Do you want to
update all the web queries on the sheet? Do the locations of TEAM NAME
change because the web queries are expanding and contracting?

Here's a couple of ideas. If you answer the above questions, I can give you
more specific help.

To update a query
Sheet1.QueryTables(1).Refresh

To update all queries
ThisWorkbook.RefreshAll

If TEAM NAME moves, I would create range names (Insert-Name-Define) for the
team name cells. Then you can find their queries like
Range("Team1").Offset(2,0).QueryTable.Refresh

where Team1 is the a named range.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top