【发布时间】:2015-04-12 20:51:54
【问题描述】:
我对编写 VBA 宏比较陌生。我编写了一个简单的宏来从网站搜索中抓取数据。我想根据选项卡“sheet1”中的单元格内容循环搜索。搜索运行良好,但似乎没有使用单元格内容。我不确定我需要做什么才能使其正常工作。您的帮助将不胜感激
Sub Get_internet_data()
For x = 1 To 3
Worksheets("Sheet1").Select
Worksheets("Sheet1").Activate
MySearch = "URL;http://www.trademe.co.nz/browse/categoryattributesearchresults.aspx?144=-1&144=-1&search=1&sidebar=1&cid=5000&rptpath=5000-"
MySearch = Cells(x, 1)
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.trademe.co.nz/browse/categoryattributesearchresults.aspx?MySearch", Destination:=Range("$C$6"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.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
End With
Next x
End Sub
【问题讨论】:
-
尝试将
"URL;http://www.trademe.co.nz/browse/categoryattributesearchresults.aspx?MySearch"更改为"URL;http://www.trademe.co.nz/browse/categoryattributesearchresults.aspx?" & MySearch