Hi My project is to download all the data from a few number of webpages, ex: www.rigzone.com so i have created a Macro to do so.
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.rigzone.com", _
Destination:=Range("$A$1"))
.Name = "www.rigzone"
.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
End Sub
The above Macro is working fine for this particular website, however when I am trying to put a different website name in place of the www.rigzone.com its not working again I have to record a second macro for the website.
I want to add all the 20 websites in Sheet 1 column A1:A20 and later on if required i can increase the length from A20 to as much as I want. So for that I used a code:-
Private Sub Extract_Click()
Dim WS As Worksheet
Set WS = ActiveSheet
For Each Cell In WS.Range("A1:A20")
ActiveWorkbook.Worksheets.Add
ThisUrl = "url;" & Cell.Value
With ActiveSheet.QueryTables.Add(Connection:= _
ThisUrl, Destination:=Range("$A$1"))
.Name = "index"
.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
Next Cell
End Sub
In this code I wanted excel to select one by one a website those are listed from column A1:A20. It will take the first website gather all the data add a sheet and store it there and then move on to the next A2 website and do the same as soon as I click the Button named "Extract".
However This code is not working, I am using MS Excel 2010. Please help me out I rally cant understand if all the parameters are same the just by changing the link why is it not running.shaumyabrata@gmail.com Please post your reply or email me with your soultion...I am really in need of a solution please anyone help...Waiting
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.rigzone.com", _
Destination:=Range("$A$1"))
.Name = "www.rigzone"
.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
End Sub
The above Macro is working fine for this particular website, however when I am trying to put a different website name in place of the www.rigzone.com its not working again I have to record a second macro for the website.
I want to add all the 20 websites in Sheet 1 column A1:A20 and later on if required i can increase the length from A20 to as much as I want. So for that I used a code:-
Private Sub Extract_Click()
Dim WS As Worksheet
Set WS = ActiveSheet
For Each Cell In WS.Range("A1:A20")
ActiveWorkbook.Worksheets.Add
ThisUrl = "url;" & Cell.Value
With ActiveSheet.QueryTables.Add(Connection:= _
ThisUrl, Destination:=Range("$A$1"))
.Name = "index"
.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
Next Cell
End Sub
However This code is not working, I am using MS Excel 2010. Please help me out I rally cant understand if all the parameters are same the just by changing the link why is it not running.shaumyabrata@gmail.com Please post your reply or email me with your soultion...I am really in need of a solution please anyone help...Waiting