我正在尝试填充Excel具有的MSN数据连接。我想从另一个工作表复制一个符号列表,并在数据馈送中使用它,就像我用逗号分隔一样,以获得最新的价格。
这是数据馈送宏,但我不知道如何输入符号。
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\Program Files\Microsoft Office\Office14\QUERIES\MSN MoneyCentral Investor Stock Quotes.iqy" _
, Destination:=Range("$A$1"))
.Name = "MSN MoneyCentral Investor Stock Quotes"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 1
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub发布于 2012-07-18 02:55:08
如果您从Sheet1运行此命令,并且股票代码的范围在您的问题中引用的文件的Sheet2中,
"C:\Program Files\Microsoft Office\Office14\QUERIES\MSN MoneyCentral投资者股票Quotes.iqy“
如果您打开它,无论如何都会引用这个底层URL,所以只需跳过本地的引用并使用它,它应该也适用于不同的版本。
Sub getQuotes()
Dim quotStr
For Each cell In Sheets("Sheet2").Range("A1:A5") 'whatever range you want
quotStr = cell + ", " + quotStr
Next
quotStr = Left(quotStr, (Len(quotStr) - 2))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://moneycentral.msn.com/investor/external/excel/quotes.asp?SYMBOL=" & quotStr _
, Destination:=Range("$A$1"))
.Name = "MSN MoneyCentral Investor Stock Quotes"-等
https://stackoverflow.com/questions/11526717
复制相似问题