I am currently running the below VBA.
Pulls multiple workbooks 2nd sheet and combines them into one. Then saves that "combined" file.
I want this to run as much as "in the background" as possible.
Any Ideas?
******
Sub Autpen()
Dim path As String
path = InputBox("Enter a file path", "AUTORUN INPUT")
Filename = Dir(path & "*.xls")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Do While Filename <> ""
Workbooks.Open Filename:=path & Filename, ReadOnly:=True
ActiveWorkbook.Sheets(2).Copy After:=ThisWorkbook.Sheets(1)
Workbooks(Filename).Close
Filename = Dir()
Loop
Call Combine
Call Create_single_file
MsgBox ("Files Merged")
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Sub Combine()
Dim J As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets(1).Copy Sheets(1)
Sheets(1).Name = "Combined"
For J = 3 To Sheets.Count
Sheets(J).Range("A1").CurrentRegion.Offset(1).Copy
Sheets(1).Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlValues
Next
With Sheets(1).UsedRange
.ColumnWidth = 22
.RowHeight = 18
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End With
End Sub
Sub Create_single_file()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim rs As Worksheet
Dim path As String
Set rs = Worksheets("Combined") 'adjust name as needed
path = InputBox("Enter a file path", "AUTORUN OUTPUT") ' adjust path as needed"
myFile = path & "Downtime.xlsx"
rs.Cells.Copy
Set NewBook = Workbooks.Add
NewBook.Worksheets("Sheet1").Range("A1").Select ' Special (xlPasteValues)(xlPasteformat)
ActiveSheet.Paste
NewBook.SaveAs Filename:=myFile
ActiveWorkbook.Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
******
Pulls multiple workbooks 2nd sheet and combines them into one. Then saves that "combined" file.
I want this to run as much as "in the background" as possible.
Any Ideas?
******
Sub Autpen()
Dim path As String
path = InputBox("Enter a file path", "AUTORUN INPUT")
Filename = Dir(path & "*.xls")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Do While Filename <> ""
Workbooks.Open Filename:=path & Filename, ReadOnly:=True
ActiveWorkbook.Sheets(2).Copy After:=ThisWorkbook.Sheets(1)
Workbooks(Filename).Close
Filename = Dir()
Loop
Call Combine
Call Create_single_file
MsgBox ("Files Merged")
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Sub Combine()
Dim J As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets(1).Copy Sheets(1)
Sheets(1).Name = "Combined"
For J = 3 To Sheets.Count
Sheets(J).Range("A1").CurrentRegion.Offset(1).Copy
Sheets(1).Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlValues
Next
With Sheets(1).UsedRange
.ColumnWidth = 22
.RowHeight = 18
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End With
End Sub
Sub Create_single_file()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim rs As Worksheet
Dim path As String
Set rs = Worksheets("Combined") 'adjust name as needed
path = InputBox("Enter a file path", "AUTORUN OUTPUT") ' adjust path as needed"
myFile = path & "Downtime.xlsx"
rs.Cells.Copy
Set NewBook = Workbooks.Add
NewBook.Worksheets("Sheet1").Range("A1").Select ' Special (xlPasteValues)(xlPasteformat)
ActiveSheet.Paste
NewBook.SaveAs Filename:=myFile
ActiveWorkbook.Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
******