我有一张工作表可以从Yahoo Finance中提取一些数据。另一张纸上包含了行情清单。我需要依次复制和粘贴每个股票行情记录,在随后的每个股票行情记录之间等待10秒钟。
Sheet1 1(单元格b1)包含用于下载的符号,而sheet2(rance A1:A40)包含所有股票。我是Excel和VBA的新手,非常感谢您的帮助。
谢谢!
答案 0 :(得分:1)
不确定我是否明白您的意思,但是您可以尝试与此类似的东西(未经测试):
Dim wb as Workbook
Dim ws_1 as Worksheet
Dim ws_2 as Worksheet
Dim ticker_coll as Collection
Dim ticker as Variant
Set ticker_coll = New Collection
Set wb = ActiveWorkbook
Set ws_1 = wb.Sheets(1)
Set ws_2 = wb.Sheets(2)
'Add all tickers from sheet 2 to the collection
Dim counter as Long
For counter = 1 To 40
ticker_coll.Add ws_2.Range("A" & counter)
Next counter
'Paste each ticker into sheet 1
For counter = 1 To 40
ws_1.Range("B" & counter) = ticker_coll(counter)
Application.Wait (Now + TimeValue("0:00:10")) 'Wait 10 seconds
Next counter