Arrays 是否激活存储在阵列中的文件的窗口?类型不匹配和下标超出范围
我正试图编写几行代码来激活存储在数组中的文件窗口,这样我就可以将数据从一个文件复制粘贴到另一个文件,但我不断得到下标超出范围或类型不匹配错误。关于语法有什么想法吗Arrays 是否激活存储在阵列中的文件的窗口?类型不匹配和下标超出范围,arrays,types,excel,type-mismatch,vba,Arrays,Types,Excel,Type Mismatch,Vba,我正试图编写几行代码来激活存储在数组中的文件窗口,这样我就可以将数据从一个文件复制粘贴到另一个文件,但我不断得到下标超出范围或类型不匹配错误。关于语法有什么想法吗 Dim Allfiles as string 'array containing files that are already opened but need to be switched between one another Dim test as integer 'index to Allfiles
Dim Allfiles as string 'array containing files that are already opened but need to be switched between one another
Dim test as integer 'index to Allfiles the number of files in Allfiles
Application.workbooks(Allfiles(Test)).activate 'type mismatch
您需要发布更多信息,例如更多的代码和您正在尝试执行的操作,但有些想法:
Dim wkb As Workbook
For Each wkb In Application.Workbooks
wkb.Activate
'Do your copy/pasting here
Next wkb
这就更完整地解释了我正在使用do循环填充数组Allfiles。如何为存储在数组中的文件包含扩展名。我只需要语法,存储在allfiles数组中的文件名包含感兴趣文件的完整目录。那么应该如何为这种情况编写语法。Application.workbook(Allfiles(Test)).activate“subscript超出范围语法错误??Allfiles(test),其中test是一个整数,等于存储在Allfiles中的文件总数。所有文件都包含需要放在前面的感兴趣文件的完整目录。