在Excel VBA中选择多个范围

时间:2015-10-26 19:22:37

标签: vba

我试图影响以下细胞范围:

A - H,J - R,W - Z和AA - AO

...使用此范围规范:

Sub FindMACTest()

    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.coffer.com/mac_find/?string=" & Range("A1"), Destination:=Range _
        ("$I$1"))
        .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 = "1"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub

我收到了错误:

Set MaPlage = Range ("A" & i & ":H" & i, 
                     "J" & i & ":R" & i, 
                     "W" & i & ":Z" & i, 
                     "AA" & i & ":AO" & i)

我做错了什么?

1 个答案:

答案 0 :(得分:0)

如上所述here,逗号必须在引号

Set maplage = Range("A" & i & ":H" & i & ",J" & i & ":R" & i & ",W" & i & ":Z" & i & ",AA" & i & ":AO" & i)