Sub test()
Dim Mypath, MyName
Dim n As Integer
n = 0
Dim MyStr() As String, wz As Integer
Mypath = ThisWorkbook.Path & "\第三方2\" ' 指定路径。
MyName = Dir(Mypath, vbDirectory) '
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
'Debug.Print MyName
n = n + 1
ReDim Preserve MyStr(n) '给动态数组重定义一个实际的大小
MyName = StrReverse(MyName)
wz = InStr(MyName, ".")
MyName = Right(MyName, Len(MyName) - wz)
MyName = StrReverse(MyName)
MyStr(n - 1) = Right(MyName, 7)
End If
MyName = Dir
Loop
Dim m As Integer
m = 0
Dim MyStr2() As String
Mypath = ThisWorkbook.Path & "\导出文件2\" ' 指定路径。
MyName = Dir(Mypath, vbDirectory) '
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
'Debug.Print MyName
m = m + 1
ReDim Preserve MyStr2(m) '给动态数组重定义一个实际的大小
MyName = StrReverse(MyName)
wz = InStr(MyName, ".")
MyName = Right(MyName, Len(MyName) - wz)
MyName = StrReverse(MyName)
MyStr2(m - 1) = Right(MyName, 7)
End If
MyName = Dir
Loop
Dim i As Integer, j As Integer
For i = 0 To n - 1
For j = 0 To m - 1
If MyStr(i) = MyStr2(j) Then
Exit For
End If
Next
If j = m Then
MsgBox ("SalesWareHouseOut_" & MyStr(i) & ".xml没有对应的药检码excel!")
End If
Next
End Sub
vba 检查一个文件夹中的文件在另一个文件夹中是否存在(不含扩展名)
最新推荐文章于 2024-09-09 15:27:40 发布