目前,我的代码循环遍历目录中的每个文件,如果文件名在范围内,则运行宏。
For Each folderIDX In PrimaryMergeFiles
Dim vTest As Variant
vTest = Application.WorksheetFunction.VLookup(folderIDX.Name, _
Worksheets("Table").Range("A1:A13"), 1, False)
If Not IsError(vTest) Then ***RUN MERGEMACRO***
我想更改它,以便它只循环遍历A1范围内具有相同名称的文件:A13
A1:A13包含名称1.doc,2.doc,3.doc
PrimaryMergeFiles是一个包含word和pptx文档的目录。
答案 0 :(得分:0)
For Each folderIDX In PrimaryMergeFiles
Dim vTest As Variant
For Each vTest in ThisWorkbook.Sheets("Table").Range("A1:A13")
If vTest.value = folderIDX then
End If
Next
Next
答案 1 :(得分:0)
试试这个:
With Application
Dim Flist As Variant
Flist = .Transpose(Sheets("Table").Range("A1:A13"))
For Each folderIDX In PrimaryMergeFiles
If Not IsError(.Match(folderIDX.Name,Flist,0)) Then Call MERGEMACRO
Next
End With
这是你的尝试吗? HTH。