I previously posted a similar question and didn't recieve a reply perhaps it demanded to much involvement. So instead of bumping I will restructure my question. I have a list of URL's in sheet 1, I am trying to have the contents of those urls imported to sheet 2. The loop part of the code works well fif i have 60 urls in sheet 1 i get (and here is the problem) 60 login pages of that website in sheet 2. Can anyone see what i am doing wrong. I think it is something simple but i dont really know what im doing when it comes to VBA. Maybe i've repeated some stuff in teh code
thanks for your help
Dan
thanks for your help
Dan
Code:
Sub Login_WebQuery()
Dim MyPost As String
Const MyUrl As String = "http://www.greyhound-data.com/login.htm?z=UFFvLs"
Const PostUser As String = "login=enter my user name here"
Const PostPassword As String = "&pass= enter my password here"
MyPost = PostUser & PostPassword
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.greyhound-data.com/login.htm?z=UFFvLs", Destination:=Range( _
"$AZ$1"))
.Name = "login.htm?z=UFFvLs"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.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
Sheets(2).Activate
i = 1
Do Until Sheets(1).Cells(i, 1) = ""
myquery = Sheets(1).Cells(i, 1)
Sheets(2).Cells(1, 1) = myquery
myrow = Sheets(2).UsedRange.Rows.Count + 1
Do
myrow = myrow - 1
Loop Until Sheets(2).Cells(myrow, 1) <> ""
myrow = myrow + 1
With Sheets(2).QueryTables.Add(Connection:= _
"URL;" & myquery, Destination:=Sheets(2).Cells(myrow, 1))
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
i = i + 1
Loop
End Sub