Excel操作界面:
CSV文件數(shù)據(jù)格式
要求
在DTPicker1里選擇日期,自動獲取和日期同名得CSV文件數(shù)據(jù)底哗。
Sub CAT()
Dim Wb As Workbook
Dim Arr, Mypath$, Myname$
Mypath = ThisWorkbook.Path & "\數(shù)據(jù)源\" '//路徑
Myname = Replace(Sheet1.DTPicker1.Value, "/", "") & ".csv" '//文件名稱
Application.ScreenUpdating = False
On Error GoTo 100: '如果找不到文件,跳轉(zhuǎn)代碼提示并退出程序锚沸。
Set Wb = Workbooks.Open(Mypath & Myname) ''//打開CSV文件
Arr = Wb.ActiveSheet.Range("A1").CurrentRegion '//將數(shù)據(jù)放到數(shù)組arr
Wb.Close False '//關(guān)閉CSV文件
With Sheet1 '//輸出數(shù)據(jù)
.Range("a5:c55555").ClearContents
.Range("A5").Resize(UBound(Arr), UBound(Arr, 2)) = Arr
End With
Application.ScreenUpdating = True
Exit Sub
100:
MsgBox "文件不存在"
End Sub
示例文件下載:
鏈接: http://pan.baidu.com/s/1i46q8hn 密碼: eggq