level 11
split()(0),然后判断instr()=1就可以了。
源文件、目标文件的目录是确定的还是动态的,好像条件还是差了一点。
2022年11月25日 11点11分
4
重新上传了图片,帮忙看看,回复好像不能发图片
2022年11月28日 06点11分
level 11
Option Explicit
Const STRLEN As Long = 22 '定长,后面这个图好像也没发现有空格
Sub abc()
Dim pth, i, a, f, d
pth = Split("源文件,结果", ",") '源文件、目标文件目录
For i = 0 To UBound(pth)
pth(i) = ThisWorkbook.Path & "\" & pth(i) & "\"
If Dir(pth(i), vbDirectory) = vbNullString Then MsgBox pth(i): Exit Sub
Next
a = [a1].CurrentRegion.Offset(1).Resize(, 1).Value
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(a) - 1
If Len(a(i, 1)) > STRLEN Then d(Left(a(i, 1), STRLEN)) = 1
Next
f = Dir(pth(0) & "*.*")
Do While Len(f) > STRLEN
If d.exists(Left(f, STRLEN)) Then FileCopy pth(0) & f, pth(1) & f
f = Dir
Loop
End Sub
2022年11月28日 11点11分
7