Hello, Whenever i run a macro to merge multiple files into 1 it fails. The macro worked perfectly in the step by step mode and in excel 2003. Im currently Using 2010 and for some reason this started to happen.
I would really appriciate some help and thank you all in advance.
Below is the code:
Sub combinefinal()
'
' combinefile Macro
' Macro recorded 1/31/2011 by pb
'
' Keyboard Shortcut: Ctrl+Shift+N
'
Dim outputcells As Excel.Range
On Error GoTo err102:
Application.ScreenUpdating = False
FilesToOpen = Application.GetOpenFilename _
(filefilter:="microsoft excel files (*xls), *.xls", _
MultiSelect:=True, Title:="files to merge")
If TypeName(FilesToOpen) = "boolean" Then
MsgBox "no files were selected"
GoTo exithandler
End If
X = 1
While X <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(X)
Sheets("Activity Summary").Select
Range("A1:I200").Select
Selection.copy
Windows("BANK ANALYSIS FY12.xlsm").Activate
Sheets("CAP CORP").Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 2).Select
ActiveSheet.Paste
FilesToOpen = Application.GetOpenFilename _
(filefilter:="microsoft excel files (*xls), *.xls", _
MultiSelect:=True, Title:="files to merge")
'allows the macro to open up xls type files. if files change you can change them here
If TypeName(FilesToOpen) = "boolean" Then
MsgBox "no files were selected"
GoTo exithandler
End If
X = 1
While X <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(X)
Sheets("Activity Summary").Select
Range("A1:I200").Select
Selection.copy
Windows("BANK ANALYSIS FY12.xlsm").Activate
Sheets("COLLECTION").Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 2).Select
ActiveSheet.Paste
FilesToOpen = Application.GetOpenFilename _
(filefilter:="microsoft excel files (*xls), *.xls", _
MultiSelect:=True, Title:="files to merge")
'allows the macro to open up xls type files. if files change you can change them here
If TypeName(FilesToOpen) = "boolean" Then
MsgBox "no files were selected"
GoTo exithandler
End If
X = 1
While X <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(X)
Sheets("Activity Summary").Select
Range("A1:I200").Select
Selection.copy
Windows("BANK ANALYSIS fy12.xlsm").Activate
Sheets("INS").Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 2).Select
ActiveSheet.Paste
exithandler:
Application.ScreenUpdating = True
Exit Sub
err102:
MsgBox Err.Description
Resume exithandler
Wend
Wend
Wend
End Sub
I would really appriciate some help and thank you all in advance.
Below is the code:
Sub combinefinal()
'
' combinefile Macro
' Macro recorded 1/31/2011 by pb
'
' Keyboard Shortcut: Ctrl+Shift+N
'
Dim outputcells As Excel.Range
On Error GoTo err102:
Application.ScreenUpdating = False
FilesToOpen = Application.GetOpenFilename _
(filefilter:="microsoft excel files (*xls), *.xls", _
MultiSelect:=True, Title:="files to merge")
If TypeName(FilesToOpen) = "boolean" Then
MsgBox "no files were selected"
GoTo exithandler
End If
X = 1
While X <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(X)
Sheets("Activity Summary").Select
Range("A1:I200").Select
Selection.copy
Windows("BANK ANALYSIS FY12.xlsm").Activate
Sheets("CAP CORP").Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 2).Select
ActiveSheet.Paste
FilesToOpen = Application.GetOpenFilename _
(filefilter:="microsoft excel files (*xls), *.xls", _
MultiSelect:=True, Title:="files to merge")
'allows the macro to open up xls type files. if files change you can change them here
If TypeName(FilesToOpen) = "boolean" Then
MsgBox "no files were selected"
GoTo exithandler
End If
X = 1
While X <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(X)
Sheets("Activity Summary").Select
Range("A1:I200").Select
Selection.copy
Windows("BANK ANALYSIS FY12.xlsm").Activate
Sheets("COLLECTION").Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 2).Select
ActiveSheet.Paste
FilesToOpen = Application.GetOpenFilename _
(filefilter:="microsoft excel files (*xls), *.xls", _
MultiSelect:=True, Title:="files to merge")
'allows the macro to open up xls type files. if files change you can change them here
If TypeName(FilesToOpen) = "boolean" Then
MsgBox "no files were selected"
GoTo exithandler
End If
X = 1
While X <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(X)
Sheets("Activity Summary").Select
Range("A1:I200").Select
Selection.copy
Windows("BANK ANALYSIS fy12.xlsm").Activate
Sheets("INS").Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 2).Select
ActiveSheet.Paste
exithandler:
Application.ScreenUpdating = True
Exit Sub
err102:
MsgBox Err.Description
Resume exithandler
Wend
Wend
Wend
End Sub