Application.OnTime Now + TimeValue("00:00:10"), "巨集2"
End Sub
複製代碼
2 2003版 中找不出錯誤
3 X = Year(Cells(1, 1))
Y = Month(Cells(1, 1))
Z = Day(Cells(1, 1))
'''''''''''''''''''''''''
A = Split(Cells(1, 1), "/")
X = A(0)
Y = A(1)
Z = A(2)作者: spermbank 時間: 2011-9-23 00:28
1.3解決 感謝大大
可是第二個問題,我還是解決不出來,以下是我的程式碼
我是用excel 2007
Sub Download()
Set f = CreateObject("excel.application")
save_file_name = "C:\test.csv" '存檔檔名
s = "2002"
i = "00"
j = "1"
k = "2010"
m = "11"
n = "31"
o = "2011"
'用excel來存檔
f.Workbooks.Open "http://ichart.finance.yahoo.com/table.csv?s=" & s ".TW&a=" & i "&b=" & j "&c=" & k "&d=" & m "&e=" & n "&f=" & o "&g=d&ignore=.csv"
'http://ichart.finance.yahoo.com/table.csv?s=2002.TW&a=00&b=1&c=2010&d=11&e=31&f=2011&g=d&ignore=.csv
f.DisplayAlerts = False
f.ActiveWorkbook.SaveAs save_file_name, 6, False '存成csv
'要直接看可以略過關閉的指令!!!
f.Quit
Set f = Nothing
Shell "explorer.exe c:\", vbMaximizedFocus
End
End Sub作者: GBKEE 時間: 2011-9-23 07:42
回復 3#spermbank 少一個連接符號 &
f.Workbooks.Open "http://ichart.finance.yahoo.com/table.csv?s=" & s ".TW&a=" & i "&b=" & j "&c=" & k "&d=" & m "&e=" & n "&f=" & o "&g=d&ignore=.csv
F.Workbooks.Open "http://ichart.finance.yahoo.com/table.csv?s=" & s & ".TW&a=" & i & "&b=" & j & "&c=" & k & "&d=" & m & "&e=" & n & "&f=" & o & "&g=d&ignore=.csv"作者: spermbank 時間: 2011-9-23 10:41
For i = 2 To Application.CountA(.Range("A:A")) '欄位有值範圍計算
symbol = .Cells(i, 1)
save_file_name = h & symbol & ".csv" '存檔檔名
If .Range("C" & i).Formula = "市" Then
'用excel來存檔
Workbooks.Open "http://ichart.finance.yahoo.com/table.csv?s=" & symbol & ".TW&a=" & ii & "&b=" & j & "&c=" & k & "&d=" & m & "&e=" & n & "&f=" & o & "&g=d&ignore=.csv"
Else
Workbooks.Open "http://ichart.finance.yahoo.com/table.csv?s=" & symbol & ".TWO&a=" & ii & "&b=" & j & "&c=" & k & "&d=" & m & "&e=" & n & "&f=" & o & "&g=d&ignore=.csv"
Sheets("Sheet1").Select
x = Application.WorksheetFunction.CountA(Range("A:A")) '欄位有值範圍計算
For i = 2 To x
If Range("C" & i).Formula = "櫃" Then
Range("A" & i, "D" & i).Select
Selection.Delete Shift:=xlUp
End If
Next
End Sub作者: GBKEE 時間: 2011-9-25 06:34
回復 16#spermbank
可以改成 Set CsvRange = OpCsv.Sheets(1).Columns(1).SpecialCells(xlCellTypeConstants).Offset(1)
Range ("A:A") =>Columns("A:A") 單欄 Columns(1)
Range ("A:B") >= Columns("A:B")
要怎麼先把第6欄(Volume)所有值都先除以1000再存入Sheet2呢?
AR = Application.Transpose(CsvRange) ->陣列從儲存格導入值時 每一維度的下限都是從1 開始 ->For i = 1 To UBound(AR)
AR = Application.Transpose(CsvRange)
For i = 1 To UBound(AR)
AR(i) = AR(i) / 1000
Next
TheRow.Offset(, 2).Resize(, CsvRange.Rows.Count) = AR