Re: [VBA ] 請問怎麼累計

看板Visual_Basic作者 (緋心刀刃)時間9年前 (2014/12/28 04:10), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
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://www.ptt.cc/bbs/Visual_Basic/M.1419711011.A.89C.html
文章代碼(AID): #1Kdn8ZYS (Visual_Basic)
文章代碼(AID): #1Kdn8ZYS (Visual_Basic)