Dear all, I have recorded three macro module for retrieve web data & it works very well, this web data contains stock high & low price ,similarly I need to analysis more about 200 stock for my personal portfolio loss gain calculation. So if I want to retrieve 200 stock , then I need to build up 200 macro record module , which is not wise decision. for this I need to implement looping vba concept as some parameter are same for all Stock , below is the recorded macro module for only three stock.
Sub Macro1()
With Sheets("web")
Sheets("web").Select
.Range("A:A").ClearContents
End With
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.exemple.org/companyGraph/cp/yearly/companygraph.php?company=ABBANK" _
, Destination:=Range("$A$1"))
.Name = "companygraph.php?company=ABBANK"
.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
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.exemple.org/companyGraph/cp/yearly/companygraph.php?company=NBL" _
, Destination:=Range("$A$7"))
.Name = "companygraph.php?company=NBL"
.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
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.exemple.org/companyGraph/cp/yearly/companygraph.php?company=EBL" _
, Destination:=Range("$A$13"))
.Name = "companygraph.php?company=NBL"
.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
here red color mark text is the individual stock name & green color text is the excel cell number where web data will be past onwards. however i will be change
just URL link & desire cell range, i need your assistance regarding this , take care every body.. nur
Bookmarks