Excel – 自动从网站获取数据到excel

我想写代码,它可以自动从网站获取数据,我想用我在单元格中的任何文本replaceURL地址(文本:“22A”)的最后部分,例如,“G1”

录制macros代码:

Sub USA() ' ' USA N-numbers Macro ' ' With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://www6.landings.com/cgi-bin/nph-search_nnr?pass=193800885&&nnumber=22A" _ , Destination:=Range("$A$1")) .Name = "nph-search_nnr?pass=193800885&&nnumber=22A" .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 = "18" .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With Columns("A:A").ColumnWidth = 28.29 Columns("B:B").ColumnWidth = 4.57 End Sub 

当我用范围(“G1”)replace22A。值得到编译错误:“预期:列表分隔符或)”任何人都知道我的代码有什么问题?

更换:

"URL;http://www6.landings.com/cgi-bin/nph-search_nnr?pass=193800885&&nnumber=22A"

附:

"URL;www6.landings.com/cgi-bin/nph-search_nnr? pass=193800885&&nnumber=" _ & Range("G1").Value