[算表] 請問怎麼累計
※ [本文轉錄自 Visual_Basic 看板 #1KO9IGN2 ]
作者: antemw (我會很有禮貌) 看板: Visual_Basic
標題: [VBA ] 請問怎麼累計
時間: Mon Nov 10 18:33:47 2014
請幫我看看程式碼
如果我有違反版規,請幫我刪除
以下是兩個程序的程式碼
主要目的是要搜尋相同資料夾中的txt檔
搜尋出 C 24 後面的字串 同時輸出檔名
C 24 後面的字串Print在 Cell(1,A)
檔名Print在 Cell(1,B)
接著讀取第二個txt檔
C 24 後面的字串Print在 Cell(2,A)
檔名Print在 Cell(2,B)
不知道為什麼
他會一直Print在 Cell(1,A) 跟 Cell(1,B)
可能我一時迷失
搞了一天了 拜託各位 T_T
- - - - - - - - - - - - - - - - - - - - - - - - -
Sub ReadtxtFiles()
Dim lRow As Long
Dim FSO As Object
Dim FL As Object
Dim Fle As Object
rpath = ThisWorkbook.Path & "\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fdr = FSO.GetFolder(rpath)
Set Fle = Fdr.Files
For Each FL In Fle
If UCase(FL.Name) Like "*.TXT" Then ProcessFile FL
Next
Set FSO = Nothing
lRow = 0
End Sub
Sub ProcessFile(FL)
Dim Fot As Object
Dim FRL As String
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fot = FSO.OpenTextFile(FL, 1, False)
Do Until Fot.AtEndOfStream
FRL = Fot.ReadLine
If FRL Like "C 24 *" Then
lRow = lRow + 1
Cells(lRow, "A") = FRL
Cells(lRow, "B") = Dir(FL)
End If
Loop
Fot.Close
Set Fot = Nothing
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
http://www.wretch.cc/user/antemw 關鍵字:男的 XD
魚說:你看不見我的淚水 因為我在水中....
水說:我能感覺到妳的淚 只因妳在我的心中...
魚需要水才能生存
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.120.184.37
※ 文章網址: http://www.ptt.cc/bbs/Visual_Basic/M.1415615632.A.5C2.html
※ 發信站: 批踢踢實業坊(ptt.cc)
※ 轉錄者: antemw (59.120.184.37), 11/11/2014 10:37:44
→
11/11 12:35, , 1F
11/11 12:35, 1F
→
11/11 12:38, , 2F
11/11 12:38, 2F
→
11/11 12:44, , 3F
11/11 12:44, 3F