|
こんにちは
0が消えないようにするにはセルの書式を文字列に変えて、そこへ読み込めば良い
です。^d^
なお、下記コードでは読み込む列をすべて文字列にしていますが、あらかじめ分か
っていればその対象列のみを文字列にすることも可能です。
Sub ReadCSV()
Dim myPath As String
Dim N As Integer
Dim D As String
Dim myVals As Variant
Dim rngDest As Range
Dim i As Integer
myPath = ThisWorkbook.Path & "\test.csv"
N = FreeFile
Open myPath For Input As #N
Line Input #N, D
Close #N
myVals = Split(D, ",")
Application.ScreenUpdating = False
Set rngDest = Workbooks.Add.Worksheets(1).Range("A1")
rngDest.Resize(, UBound(myVals) + 1).EntireColumn.NumberFormat = "@"
Open myPath For Input As #N
Do Until EOF(N)
Line Input #N, D
myVals = Split(D, ",")
rngDest.Resize(, UBound(myVals) + 1).Value = myVals
Set rngDest = rngDest.Offset(1)
Loop
Close #N
Application.ScreenUpdating = True
End Sub
|
|