Skipping blank cells in excel vba

rolando

New Member
Joined
Apr 18, 2011
Messages
46
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!

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:
Wow that worked! thanks so much! all i had to change was the range instead of "rt1" i changed it to "rt:rt" since it was many rows. it works beautifully now.
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Wow that worked! thanks so much! all i had to change was the range instead of "rt1" i changed it to "rt:rt" since it was many rows. it works beautifully now.
As I said, I am not familiar with QueryTables, so I had to guessing a little as to what the code might be doing. I'm glad you were able to work out the changes you needed to make to correct the code I posted.
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,020
Members
449,203
Latest member
tungnmqn90

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top