|
こんな感じでいかがでしょうか。^d^
Sub ReadTextFile()
Dim myPath As String
Dim Fname As String
Dim N As Integer
Dim D As String
Dim rngDest As Range
Set rngDest = Workbooks.Add.Worksheets(1).Range("A1")
myPath = ThisWorkbook.Path & "\横浜\"
Fname = Dir(myPath & "*.*")
Do Until Fname = ""
N = FreeFile
Open myPath & Fname For Input As #N
Line Input #N, D
rngDest.Value = D
Set rngDest = rngDest.Offset(1)
Do Until EOF(N)
Line Input #N, D
If Left$(D, 1) = "D" Then
rngDest.Value = D
Set rngDest = rngDest.Offset(1)
End If
Loop
Close #N
Fname = Dir()
Loop
rngDest.Offset(-1).CurrentRegion.TextToColumns , xlDelimited, comma:=True, Space:=True
End Sub
なお、このコードは
>1列目が「D」(1文字だけです)になっている行すべて
ではなく一行の一文字目が「D」の行を抽出しています。
|
|