我在下一行收到运行时错误“1004”错误。
With ActiveSheet.QueryTables.add(Connection:=connstring, Destination:=Range("$b$2"))
Destination:=Range("$b$1"))
变量 connstring 似乎是导致问题的原因。如何在此连接语句中正确使用变量名?
帮助将不胜感激
Sub add()
For x = 1 To 58000
Worksheets("PAGES").Select
Worksheets("PAGES").Activate
connstring = "http://www.name-list.net/russia/1"
With ActiveSheet.QueryTables.add(Connection:=connstring, Destination:=Range("$b$2"))
Destination:=Range("$b$1"))
.Name = "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 = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Next x