Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Excel/VBA to fetch data from webpage?

Status
Not open for further replies.

bompa

Programmer
Joined
Mar 20, 2002
Messages
4
Location
FI
Is there anyway to do anything of this described below. I Would be very very thankful.

1. I would like Excel/VBA to go to an adress like this..
and fetch the one where 20020327 is the date of today. Get that data into Excel and open it..

2. Is there some else way to automatic get stock data to excel?
Examples?

/Thank you very much in advance!
 
Try using this. In stDate I've changed the Day from now to now - 7 as there is no data available for the last week. This is mainly (almost totally!!) recorded so you might want to look into it further.


Sub GetWebData()
Dim stDate As String

On Error GoTo Mash

ChDir ThisWorkbook.Path
stDate = Format(Year(Now), "####") & Format(Month(Now), "0#") & Format(Day(Now) - 7, "0#")

With ActiveSheet.QueryTables.Add(Connection:= _
"URL; & stDate & "k_isin.xls", _
Destination:=Worksheets("Data").Range("A1"))
.Name = stDate & "k_isin"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingRTF
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With

Exit Sub
Mash:
MsgBox "Error : " & Err.Description

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top