[英]VBA Error - Subscript out of range - Runtime Error 9
Dim LastRow As Long
With Workbooks("SampleBook").Sheets("SampleSheet")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
I have been running this code for over a month now. 我已经运行此代码一个多月了。 I had no issues.
我没有问题。 Suddenly, for the past two days, it's throwing the subscript out of range - run time error(9).
突然,在过去的两天里,它使下标超出了范围-运行时错误(9)。
Not sure what's going on! 不知道发生了什么!
Your help is appreciated :) 感谢您的帮助:)
Thank you! 谢谢!
Figured it out!! 弄清楚了!! I had enabled the show file extension option in folder options.
我已在文件夹选项中启用了显示文件扩展名选项。 I needed to add the extension to my workbook name.
我需要将扩展名添加到我的工作簿名称中。 The following modification worked
以下修改有效
With Workbooks("SampleBook.xlsm").Sheets("SampleSheet") LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row End With 使用Workbooks(“ SampleBook.xlsm”)。Sheets(“ SampleSheet”)LastRow = .Cells(.Rows.Count,“ A”)。End(xlUp).Row End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.