geospatial
Active Member
- Joined
- Sep 2, 2008
- Messages
- 290
My excel 2007 macro enabled file always crashes when trying to save after running a macro. The VBA I am running is below and it completes fine. Its just after it completes and I go to save the file it crashes.
Code:
Dim folderPath As String
Dim fileName As String
Sub master()
Dim wb as Workbook
folderpath = "C:\Working Folder\2011\"
fileName = Dir(folderPath & "*.xls")
Call clear_sigmaster
Do while fileName <> ""
Set wb = workbooks.open(folderPath & filename)
call importsig
fileName = Dir()
Loop
End Sub
sub clear_sigmaster()
Sheets("Sig_Master").Select
Range("A2:GG65536").Select
Selection.Delete Shift:=xlUp
End Sub
Sub importSig()
Windows(filename).Activate
Sheets("Sigacts").Select
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Range("A1:AQ65536").Select
Selection.Copy
Windows("Sigacts 2011.xlsm").Activate
Sheets("Paste_Here").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Windows(fileName).Activate
ActiveWindow.Close
Sheets("Sig_Master").Select
Range("A1").Select
Sheets("Paste_Here").Select
Range("A1").Select
Range(Range("AQ65536").End(xlUp), "A2").Copy Sheets("Sig_Master").Range("A65536") _
.End(xlUp).Offset(1,0)
Sheets("Paster_Here").Cells.Clear
End Sub