I had some code that was working fine for weeks and all of a sudden it no longer works anymore. I'm still a novice at vba. Do any of you have an idea as to why this might happen.
here is the code:
here is the code:
Code:
Sub Five_Year()
Sheets("Raw5").Cells.ClearContents
Dim Stock As String
Dim xConnect As Object
ST = Sheets("Grading Sheet").Range("B2") ' ticker symbol of stock
SD = (Sheets("Grading Sheet").Range("C11") - DateValue("January 1, 1970")) * 86400 'today - 365*5
ED = (Sheets("Grading Sheet").Range("C12") - DateValue("January 1, 1970")) * 86400 'todays date
'Retrieve 5 Yr Data
With Sheets("Raw5").QueryTables.Add(Connection:= _
"finance.yahoo.com/quote/" & ST & "/history?period1=" & SD & "&period2=" & ED & "&interval=1mo&filter=history&frequency=1wk" _ 'ignore faulty link
, Destination:=Sheets("Raw5").Range("$A$1"))
.Name = "5Yr"
.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