I have a code that is running fine on other computers, but get runtime error 9 on my one.
Here is the code:
Private Sub cmdLE_Click()
Workbooks.Open Filename:=("d:\StaffRecord\YearServing.xls")
With Workbooks("YearServing").Sheets("sheets1")<runtime error 9>
.Columns("A:A").Select
Selection.ColumnWidth = 15
Selection.ShrinkToFit = True
~~~
End With
I have done a research on error 9 and seems the reason of happening is excel cannot access to the file. However, that is not the problem, the excel can find that file and open it properly.
When I use the mouse to point to the error statement it shows:
" Workbooks("YearServing").Sheets("sheets1") = < Subscript out of range > "
The most strange thing is it only happen on my compter, not others. Is that due to any setting problems or the code?
Bookmarks