从CSV文件转换为Excel的多个Sheet

来源:互联网 发布:淘宝盗图修改技巧 编辑:程序博客网 时间:2024/05/21 19:31
Sub Macro3()
    Application.ScreenUpdating = False
    Set oConn = CreateObject("ADODB.CONNECTION")
    oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ThisWorkbook.Path & ";Extended Properties=""text;HDR=Yes;FMT=Delimited"""
    Set oRS = CreateObject("ADODB.RECORDSET")
        'Now actually open the text file and import into Excel
    oRS.Open "SELECT * FROM 201403_OSA_BY_SKU_DT.csv", oConn, 3, 1, 1
    While Not oRS.EOF
        Sheets.Add After:=Sheets(Sheets.Count)
        ActiveSheet.Range("A1").CopyFromRecordset oRS, 1000000
    Wend
    Application.ScreenUpdating = True
End Sub
0 0
原创粉丝点击