・(2017.06.16) Excel VBAを使ったCSVファイル読み込み時の高速化、タブ区切り対応、ダブルクォーテーション削除のコツ
Sub CSVファイルの読み込み() Dim fso As New Scripting.FileSystemObject Dim csvFile As Object Dim csvData As String Dim splitcsvData As Variant Dim i As Integer Dim j As Integer Set csvFile = fso.OpenTextFile("K:\CSV_Data\顧客データ.csv", 1) i = 1 Do While csvFile.AtEndOfStream = False csvData = csvFile.ReadLine splitcsvData = Split(csvData, ",") j = UBound(splitcsvData) + 1 Sheet2.Range(Sheet2.Cells(i, 1), Sheet2.Cells(i, j)).Value = splitcsvData i = i + 1 Loop csvFile.Close Set csvFile = Nothing Set fso = Nothing End Sub
[Excel][VBA][Office]
0 件のコメント:
コメントを投稿