| 
    
     |  | ▼とりとる さん: CSVをOPENで読み込んで、必要な条件でデータを読み込むようにしてはどうですか?
 サンプルとして、strSplit(1)で、”なごや” と入っているデータのみ取り込む。
 
 strSplit(0)・・・1列目のデータ
 strSplit(1)・・・2列目のデータ
 strSplit(2)・・・3列目のデータ  と、35列あれば、strSplit(0)〜strSplit(34)までです。
 
 少しは、早くなると思います。
 必要な条件データは、FORM画面を作成し、取込めばいいかと。
 参考までに・・・
 
 
 Sub CSV入力1()
 Dim varFileName As Variant
 Dim intFree As Integer
 Dim strRec As String
 Dim strSplit() As String
 Dim i As Long, j As Long
 
 'クリップボードにコピーした内容をクリアする
 Application.CutCopyMode = False
 '画面表示停止
 Application.ScreenUpdating = False
 
 varFileName = Application.GetOpenFilename(FileFilter:="CSVファイル(*.csv),*.csv", _
 Title:="CSVファイルの選択")
 If varFileName = False Then
 Exit Sub
 End If
 
 intFree = FreeFile '空番号を取得
 Open varFileName For Input As #intFree 'CSVファィルをオープン
 
 '抽出先をクリアする
 Sheet2.Range("A:Z").ClearContents
 
 Debug.Print Format(Time, "hh:mm:ss")
 
 i = 0
 Do Until EOF(intFree)
 Line Input #intFree, strRec '1行読み込み
 strSplit = Split(strRec, ",") 'カンマ区切りで配列へ
 
 '*** 必要なデータのみ読み込む 2列目がなごやのデータ
 If strSplit(1) = "なごや" Then
 i = i + 1
 For j = 0 To UBound(strSplit)
 
 Sheet2.Cells(i, j + 1).Value = strSplit(j)
 
 Next
 '配列をそのまま入れる方法も、ただし全て文字列として入力される
 'Range(Cells(i, 1), Cells(i, UBound(strSplit) + 1)) = strSplit
 End If
 Loop
 
 Close #intFree
 
 Debug.Print Format(Time, "hh:mm:ss")
 '画面表示
 Application.ScreenUpdating = True
 'クリップボードにコピーした内容をクリアする
 Application.CutCopyMode = False
 
 End Sub
 
 
 |  |