How to do it in Macro - 30 Nov?

E

Eric

Does anyone have any suggestions on how to do it in macro?
I would like to load the page from page 1 to 10.

Create a loop to run from 1 to 10

http://www.uwants.com/forumdisplay.php?fid=845&page=1
After it load the first page into data worksheet, then copy everything under
F column on load page into the first column under Summary worksheet.

http://www.uwants.com/forumdisplay.php?fid=845&page=2
After it load the second page into data worksheet, then copy everything
under F column on load page into the second column under Summary worksheet.

....

http://www.uwants.com/forumdisplay.php?fid=845&page=10
After it load the tenth page into data worksheet, then copy everything under
F column on load page into the tenth column under Summary worksheet.

Does anyone have any suggestions on how to do it in macro?
Thanks in advance for any suggestions
Eric
 
S

Shane Devenshire

Hi,

i'm not sure what exactly you want to do, however, here is the general
sysntax of a loop:

For Counter = 1 to 10
'Your code
Next Counter

Although you can't record a loop, you may be able to record what you want
inside the loop. Turn on the recorder by choosing Tools, Macro, Record new
Macro, give it a name (without spaces) and click OK. Do the steps you want
the macro to do and then turn of the recorder where you turned it on.

If this helps, please click the Yes button.

Cheers,
Shane Devenshire
 
E

Eric

Thank everyone very much for suggestions
Following code is generated by recording Macro.
Could you please tell me how I can insert the Counter into the web link? and
change the column location for pasting selection?

If the counter is 1, then paste into Columns("A:A").Select under Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under Summary
worksheet.

....

If the counter is 10, then paste into Columns("J:J").Select under Summary
worksheet.

Do you have any suggestions?
Thank you very much for any suggestions
Eric

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub
 

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