作者Yaiba (緋心刀刃)
看板Visual_Basic
標題Re: [VBA ] 請問怎麼累計
時間Sun Dec 28 04:10:02 2014
Option Explicit
Private Const ForReading As Integer = 1
Private lRow As Long
Sub ReadtxtFiles()
Dim sReadPath As String
Dim FSO As Object
Dim Fdr As Object
Dim Fles As Object
Dim Fle As Object
lRow = 0
sReadPath = ThisWorkbook.Path & "\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fdr = FSO.GetFolder(sReadPath)
Set Fles = Fdr.Files
For Each Fle In Fles
If UCase(Fle.Name) Like "*.TXT" Then
Call ProcessFile(Fle)
End If
Next
Set FSO = Nothing
End Sub
Sub ProcessFile(FL)
Dim FSO As Object
Dim Fot As Object
Dim sLineData As String
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fot = FSO.OpenTextFile(FL, ForReading, False)
Do Until Fot.AtEndOfStream
sLineData = Fot.ReadLine
If sLineData Like "C 24 *" Then
lRow = lRow + 1
Cells(lRow, "A") = sLineData
Cells(lRow, "B") = Dir(FL)
End If
Loop
Fot.Close
Set Fot = Nothing
End Sub
--
常發人好人名片
Yaiba:您好,我是好人
幫正妹組電腦送到府
外加一年到府維護
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.193.239.6
※ 文章網址: http://webptt.com/m.aspx?n=bbs/Visual_Basic/M.1419711011.A.89C.html