Hello,
Below is a macro that i had written in 2007 that oes not work anymore and i have no idea why. It gets as far as opening the first file but then stops with no error. It's supposed to open a file browser, then i click on the first of 3 files then it copies the data and pastes it back into the main file. If someone could please help it would be much appreciated. Im not very good with VBA, i taught what little i know from google.
Thank you
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
'incase of an error the macro will go to errhandler and perform end sub
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("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
Below is a macro that i had written in 2007 that oes not work anymore and i have no idea why. It gets as far as opening the first file but then stops with no error. It's supposed to open a file browser, then i click on the first of 3 files then it copies the data and pastes it back into the main file. If someone could please help it would be much appreciated. Im not very good with VBA, i taught what little i know from google.
Thank you
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
'incase of an error the macro will go to errhandler and perform end sub
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("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