Geronimo9791
New Member
- Joined
- Nov 25, 2013
- Messages
- 2
hi all,
see below the VBA code I programmed (new at this). The debugger gets always stuck on the same line highlighted in red. It's probably something stupid but I'm not seeing it. thx in advance for the help
regards
Sub GetOne()
' Download one stock only
Dim QuerySheet As Worksheet
Dim DataSheet As Worksheet
Dim EndDate As Date
Dim StartDate As Date
Dim Symbol As String
Dim qurl As String
Dim nQuery As Name
Dim i As Integer
Application.ScreenUpdating = True
Application.DisplayAlerts = False
Application.Calculation = xlCalculationAutomatic
Set DataSheet = ActiveSheet
StartDate = DataSheet.Range("I1").Value
EndDate = DataSheet.Range("I2").Value
Symbol = DataSheet.Range("G1").Value
Range("L1").CurrentRegion.ClearContents
'construct the URL for the query
qurl = "http://ichart.finance.yahoo.com/table.csv?s=" & Symbol
qurl = qurl & "&a=" & Month(StartDate) - 1 & "&b=" & Day(StartDate) & _
"&c=" & Year(StartDate) & "&d=" & Month(EndDate) - 1 & "&e=" & _
Day(EndDate) & "&f=" & Year(EndDate) & "&g=d" & Range("C4") & "&ignore=.csv"
QueryQuote:
With ActiveSheet.QueryTables.Add(Connection:="URL;" & qurl, Destination:=DataSheet.Range("L1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.QueryTable.Refresh BackgroundQuery:=False
.SaveData = True
End With
Range("L1").CurrentRegion.TextToColumns Destination:=Range("L1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, other:=False
Columns("L:R").Select
Selection.ColumnWidth = 8
Application.DisplayAlerts = True
RemoveNames
Range("A1").Select
End Sub
see below the VBA code I programmed (new at this). The debugger gets always stuck on the same line highlighted in red. It's probably something stupid but I'm not seeing it. thx in advance for the help
regards
Sub GetOne()
' Download one stock only
Dim QuerySheet As Worksheet
Dim DataSheet As Worksheet
Dim EndDate As Date
Dim StartDate As Date
Dim Symbol As String
Dim qurl As String
Dim nQuery As Name
Dim i As Integer
Application.ScreenUpdating = True
Application.DisplayAlerts = False
Application.Calculation = xlCalculationAutomatic
Set DataSheet = ActiveSheet
StartDate = DataSheet.Range("I1").Value
EndDate = DataSheet.Range("I2").Value
Symbol = DataSheet.Range("G1").Value
Range("L1").CurrentRegion.ClearContents
'construct the URL for the query
qurl = "http://ichart.finance.yahoo.com/table.csv?s=" & Symbol
qurl = qurl & "&a=" & Month(StartDate) - 1 & "&b=" & Day(StartDate) & _
"&c=" & Year(StartDate) & "&d=" & Month(EndDate) - 1 & "&e=" & _
Day(EndDate) & "&f=" & Year(EndDate) & "&g=d" & Range("C4") & "&ignore=.csv"
QueryQuote:
With ActiveSheet.QueryTables.Add(Connection:="URL;" & qurl, Destination:=DataSheet.Range("L1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.QueryTable.Refresh BackgroundQuery:=False
.SaveData = True
End With
Range("L1").CurrentRegion.TextToColumns Destination:=Range("L1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, other:=False
Columns("L:R").Select
Selection.ColumnWidth = 8
Application.DisplayAlerts = True
RemoveNames
Range("A1").Select
End Sub