Excel Macros - SubIndice out of range

0

I am developing a Macros in Excel that takes web addresses from a range of defined cells and makes a query, but when I take the address and make the query it shows me an error message

  

"Subscript out of range".

This is the code I am working on, the part in bold is where the error is marking me.

Sub ConsultaGlobal()

    Application.Run "'Keywords Research Okey Mkt.xlsm'!SeleccionGlobal"
    AuxKW = Selection.Count

    For I = 1 To AuxKW Step 1


       **With Sheets("'Resultado Consulta'").QueryTables.Add(Connection:= _
        "URL;" + Sheets("Resultado Consulta").Cells(I, 2) _
        , Destination:=Range("'Recoleccion de Datos'!A1"))**
        .CommandType = 0
        .Name = I
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .BackgroundQuery = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False

        Sheets("Recoleccion de Datos").Range("SERP").Copy
        Sheets("Resultado Consulta").Range(I + 1, 3).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        Sheets("Recoleccion de Datos").Cells.Clear
        Sheets("Resultado Consulta").Select

        End With

        Next


End Sub
    
asked by DavidAps 26.12.2018 в 21:46
source

0 answers