这个vba给我一个后台刷新错误,我怎么能摆脱这个调试

时间:2017-03-17 13:20:03

标签: excel vba

这个vba给我一个后台刷新错误,我怎么能摆脱这个调试

Sub Macro21()
'
' Macro21 Macro
'

'
    Dim url As String
    Dim namedt As String
    url = Sheets("sheet18").Range("G2")
    namedt = Sheets("sheet18").Range("I2")

    Range("E2").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://www.sec.gov" & "url", Destination:=Range("$A$10"))
        .Name = "namedt"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "300,301,302"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub

1 个答案:

答案 0 :(得分:0)

"URL;https://www.sec.gov" & "url", Destination:=Range("$A$10"))
.Name = "namedt"

失去了引号,因此:

"URL;https://www.sec.gov" & url, Destination:=Range("$A$10"))
.Name = namedt

我在A10中什么都没得到,但至少它运行了。