I am using code that automatically retrieves data from a website. In VBA, I have set up loop to loop through my list of web addresses (in column A in sheet one), retrieves the data, does a bunch of calculations, and then loops to the net address. However, I have found that some addresses do not return any data and cause the previous sets of data to be overwritten (due to some of my formatting code). I am looking for some code to skip the steps if I am unable to retrieve any data. Any help would be greatly appreciated! Thanks in advance!

Loop code:


 Sub getwebdata()
    Dim Erw, Frw, Lrw
    Frw = 1
    Lrw = Range("A" & Rows.Count).End(xlUp).Row
    For Erw = Frw To Lrw
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;" & Range("A" & Erw).Value, Destination:=Range("B" & Erw))
        .Name = "XXX"
        .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

     "my saved calculations"

    Next Erw

End Sub


Clinton