|
Hirofumiさんが立派なコードを提示されてますのでもう必要ないかもしれません
が一応修正してみましたので。^d^
(一括で読み込みvbLFで行に分けるようにしてみました。)
Sub ReadCSV()
Dim myPath As String
Dim Fname As String
Dim N As Integer
Dim rngDest As Range
Dim myArray0 As Variant
Dim myArray As Variant
Dim D As String
Dim i As Integer
myPath = ThisWorkbook.Path & "\"
Set rngDest = Worksheets("Sheet1").Range("A1")
Application.ScreenUpdating = False
Fname = Dir(myPath & "*.csv")
Do Until Fname = ""
N = FreeFile
Open myPath & Fname For Input As #N
D = InputB(LOF(N), N)
D = StrConv(D, vbUnicode)
Close #N
myArray0 = Split(D, vbLf)
For i = 0 To UBound(myArray0)
myArray = Split(CStr(myArray0(i)), ",")
rngDest.Resize(1, UBound(myArray) + 1).Value = myArray
Set rngDest = rngDest.Offset(1)
Next
Fname = Dir()
Loop
Application.ScreenUpdating = True
Set rngDest = Nothing
End Sub
|
|