I have a problem with the following code and I cannot get it to run. I
am getting a "Run-time error
'9': Subscript out of range" error when I try to run this code. Here
is the code:
Sub openfilesInALocation()
Dim i As Integer, wb As Workbook
With Application.FileSearch
..NewSearch
..LookIn =3D "C:\Documents and Settings\chrisf\My Documents\vbatest"
..SearchSubFolders =3D False
..Filename =3D "*.xls"
..Execute
For i =3D 1 To .FoundFiles.Count
'Open each workbook
Set wb =3D Workbooks.Open(Filename:=3D.Foun=ADdFiles(i))
'Perform the operation on the open workbook
-----------> Errors on the following line:
wb.Worksheets("sheet1").Range(=AD"A1").Select
'Save and close the workbook
wb.Save
wb.Close
'On to the next workbook
Next i
End With
End Sub
If anyone can solve this for me I would appreciate the help!
-Chris
Bookmarks