Reducing code by looping

O

Ocean

I have a need to write some code in VBA for Word.
I already have some code that goes to a website downloads a football table
and then pastes/formats it in Word automatically.
This works fine for the first table, but there there are 4tables I need in
total. Each one has its own web page.
How can I loop through each web page and download each table and the
sequentially paste/format them into the word document.

I have a counter that goes up, and makes this:
httppage = "http://www.footyresults.com/league" & League & ".html"
So this returns
http://www.footyresults.com/league1.html
http://www.footyresults.com/league2.html
http://www.footyresults.com/league3html
http://www.footyresults.com/league4html

I want this to be used in the code that determines the webpage to go to.

Any suggestions as to how i can loop through the main internet download
table code, but each time reassigning the "httppage" to the next html page?
I do not want to repeat the full code for each table !
Any suggestions would be really appreciated...
Thanks
 
L

Lene Fredborg

You should be able to do something like this (I assume "League" is your
counter):

For Leauge = 1 to 4
httppage = "http://www.footyresults.com/league" & League & ".html"
[insert your code that downloads the table etc. – use httppage as the
address]
Next Leauge

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

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

Top