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