我有一個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