0
有沒有方法可以查找數組中的物品數量?VBA代碼查找陣列中物品的數量
我的txt文件列表:
C.txt
D.txt
G.txt
H.txt
有了下面的代碼,我聚合的TXT文件有輸出只有一個TXT文件(output.txt的)。
但我只需要在服務器的路徑中存在所有四個txt文件時才匯聚文件txt,否則我需要在代碼中提醒消息。
你能幫我嗎?
預先感謝您。
Option Compare Database
Dim path
Function go()
Dim ArrTest() As Variant
Dim I As Integer
Dim StrFileName As String
path = CurrentProject.Path
Ouput:
ArrTest = Array("C", "D", "G", "H")
file_global = "" & path & "\Output.txt"
fn = FreeFile
Open file_global For Output As fn
Close
For I = 0 To UBound(ArrTest)
StrFileName = "" & path & "\Output_" & ArrTest(I) & ".txt"
fn = FreeFile
Open StrFileName For Input As fn
Open file_global For Append As fn + 1
Line Input #fn, datum
Do While Not EOF(fn)
Line Input #fn, datum
datums = Split(datum, Chr(9))
For d = 0 To UBound(datums)
If d = 0 Then
datum = Trim(datums(d))
Else
datum = datum & ";" & Trim(datums(d))
End If
Next
Print #fn + 1, datum
Loop
Close
Next I
Application.Quit
End Function