S
Snowman
Sorry, I'm really, really ignorant when it comes to programming macros. I
currently have an Excel file with two worksheets. Worksheet 2 is named
"Links" and consists of a list of links (not in hypertext format... not sure
of this could be the problem or not). Sheet 1 is named Data, and is
currently blank.
What I want to do is be able to run this macro in sheet 1 and have it open
the top link in sheet 2, cut the second table from that webpage, and paste it
into the first available rows on sheet 1. I then want to be able to repeat
and have it do the same with the second link, and then the third, and so on,
until I have copied that chart from each of the 273 webpages linked on sheet
2.
Unfortunately, by attempts to do so are not working. I get run-time error
#1004, and a message that the address isn't valid. Here's the code:
Sub URL_Get_Data()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & _
Sheets("Links").Select, _
Destination:=Cells(Rows.Count, 1).End(xlUp)(2))
.BackgroundQuery = True
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.Refresh BackgroundQuery:=True
.SaveData = True
End With
End Sub
Any help as to where I've gone wrong would be greatly appreciated.
currently have an Excel file with two worksheets. Worksheet 2 is named
"Links" and consists of a list of links (not in hypertext format... not sure
of this could be the problem or not). Sheet 1 is named Data, and is
currently blank.
What I want to do is be able to run this macro in sheet 1 and have it open
the top link in sheet 2, cut the second table from that webpage, and paste it
into the first available rows on sheet 1. I then want to be able to repeat
and have it do the same with the second link, and then the third, and so on,
until I have copied that chart from each of the 273 webpages linked on sheet
2.
Unfortunately, by attempts to do so are not working. I get run-time error
#1004, and a message that the address isn't valid. Here's the code:
Sub URL_Get_Data()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & _
Sheets("Links").Select, _
Destination:=Cells(Rows.Count, 1).End(xlUp)(2))
.BackgroundQuery = True
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.Refresh BackgroundQuery:=True
.SaveData = True
End With
End Sub
Any help as to where I've gone wrong would be greatly appreciated.