|
Sub シート振り分け()
Dim MyF As String, Buf As String, Sn As String
Dim WS As Worksheet
Dim Ary As Variant
With Application
MyF = .GetOpenFilename("CSVファイル(*.csv),*.csv")
If MyF = "False" Then Exit Sub
.ScreenUpdating = False
End If
For Each WS In Sheets(Array("Sheet1", "1000", "1500", "2000"))
WS.Cells.ClearContents
Next
Open MyF For Input Access Read As #1
Do Until EOF(1)
Line Input #1, Buf
Ary = Split(Buf, ",")
Sheets("Sheet1").Range("A65536").End(xlUp).Offset(1) _
.Resize(, UBound(Ary) + 1).Value = Ary
Select Case Ary(2)
Case 1000, 1500, 2000
Sn = CStr(Ary(2))
Sheets(Sn).Range("A65536").End(xlUp).Offset(1) _
.Resize(, UBound(Ary) + 1).Value = Ary
End Select
Erase Ary
Loop
Close #1
Application.ScreenUpDating = True
End Sub
|
|