- Dec 11, 2014
- Office Version
I have a VBA code that pulls two worksheets from 4 different workbooks that are all in the same folder plus adds two blank worksheets at the end. The files that it pulls the worksheets from are all .xlsx files, while the workbook that they are pulled into is an .xlsm file. It works fine on three of my computers, but when I run it on the client's computer, I get a "Subscript Out Of Range (error 9)". I highlighted the area below that highlights when I debug the error. I do change the Path correctly. I am on Office 365 if that matters. Any thoughts on what could be causing this error?
Rich (BB code):
Sub ICEDR() Dim Path As String Path = "F:\Excel Help\Edna\Inversion Comunitaria EDR\" Dim FileName As String FileName = Dir(Path & "*.xlsx") Dim ws As Worksheet Application.ScreenUpdating = False Application.DisplayAlerts = False Do While FileName <> "" Workbooks.Open Path & FileName For Each ws In ActiveWorkbook.Sheets ws.Copy After:=Workbooks("BD - Inversion Comunitaria EDR").Worksheets(Workbooks("BD - Inversion Comunitaria EDR").Worksheets.Count) Next ws Workbooks(FileName).Close FileName = Dir() Loop Worksheets(1).Delete Application.ScreenUpdating = False Application.DisplayAlerts = False Sheets.Add After:=ActiveSheet ActiveSheet.Name = "Peticiones" Sheets.Add After:=ActiveSheet ActiveSheet.Name = "Proyectos" End Sub
Last edited by a moderator: