hey folks,
I can't seem to figure out how to use an if statement to skip downloading data for a cell that is currently blank. What i did below is i tried to make the program think that if there is any text or number in cell b8 (defined as symbol4) then it should skip that entire downloading section of code.
Obviously greater than zero doesn't work since it is only text that should appear in cell b8. So the cell in b8 will either have text or be blank, so if it is blank then skip, if not then proceed with the downloader code. I know this should be a simple fix but can't figure out the proper way. Also i put "resume next" so it can proceed to the next part, which is identical lines of code. The entire program is basically 25 of that entire code snippet seen below. so at anytime maybe 10 of the 25 sections should actually be downloading the data, since 10 of the 25 cells will have data, the other cells will be blank.
Any input would be helpful. Thanks!
I can't seem to figure out how to use an if statement to skip downloading data for a cell that is currently blank. What i did below is i tried to make the program think that if there is any text or number in cell b8 (defined as symbol4) then it should skip that entire downloading section of code.
Obviously greater than zero doesn't work since it is only text that should appear in cell b8. So the cell in b8 will either have text or be blank, so if it is blank then skip, if not then proceed with the downloader code. I know this should be a simple fix but can't figure out the proper way. Also i put "resume next" so it can proceed to the next part, which is identical lines of code. The entire program is basically 25 of that entire code snippet seen below. so at anytime maybe 10 of the 25 sections should actually be downloading the data, since 10 of the 25 cells will have data, the other cells will be blank.
Any input would be helpful. Thanks!
Code:
symbol4 = Range("b8").value
If symbol4 < 0 Then Resume Next
If symbol4 > 0 Then
With Worksheets("Beta Historical").QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=" & symbol4 & "&a=00&b=3&c=2009&d=09&e=10&f=2011&g=d&ignore=.csv" _
, Destination:=Worksheets("Beta Historical").Range("as1"))
.name = "import"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "1"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End If
Last edited: