我有一个excel电子表格和产品名称列表。我想要做的是(1)将这些产品名称分成5行,(2)设置一个从指定网站(clinicaltrials.gov)提取数据的网站搜索,并将其填充到每个电子表格下方的行中。 (2)现在对我来说更重要和更具挑战性。我知道我必须运行一个遍历所有产品名称的循环。但在我关注循环之前,我需要帮助弄清楚如何编写执行网站搜索的代码。在Excel上进行网站搜索
我接收一些帮助:
以下Excel VBA一小段代码片段将采取细胞与构造的URL的形式:
="URL;http://clinicaltrials.gov/ct2/show?term="& [Cell Reference to Drug name here] &"&rank=1"
和输出4行,例如:
Estimated Enrollment: 40
Study Start Date: Jan-11
Estimated Study Completion Date: Apr-12
Estimated Primary Completion Date: April 2012 (Final data collection date for primary outcome measure)
With ActiveSheet.QueryTables.Add(Connection:= _ ActiveCell.Text, Destination:=Cells(ActiveCell.Row, ActiveCell.Column + 1)) .Name = "Clinical Trials" .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 = "12" .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With
你能发布一个样品药物名称,以便我可以看到查询结果吗? – JimmyPena