[英]Open array files subscript out of range
I'm trying to open up a series of xlm files stored in an array, but the error keeps popping up that says that the subscript is out of range.我试图打开存储在数组中的一系列 xlm 文件,但错误不断弹出,表明下标超出范围。 Any advice?
有什么建议吗? Thanks
谢谢
Dim AllFiles() As String
Dim count, test, StartRow, LastRow, LastColumn As Long
test = count
Do While (test >= 0)
Workbooks.Open Filename:=AllFiles(test) 'subscript out of range
test = test - 1
Loop
This doesn't address the root cause (what ever that may be) but is a more natural way to loop an array这并没有解决根本原因(可能是什么),而是一种更自然的循环数组方式
For test = UBound(AllFiles) to LBound(AllFiles) Step -1
Workbooks.Open Filename:=AllFiles(test)
Loop
By the way, your dim statement Dim count, test, StartRow, LastRow, LastColumn As Long
declares all items except LastColumn
as Variant
顺便说一句,您的昏暗语句
Dim count, test, StartRow, LastRow, LastColumn As Long
将除LastColumn
之外的所有项目声明为Variant
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.