Hello. This first code opens all files in a folder and renames the first tab in each open file. The second adds the content from each tab into one tab. Is there a way that I can combine the two codes into one? So taht I don't have to run two macros?
Code 1
Sub RenameSheet1()
Dim FileExtension As String, FilesInFolder As String
Dim FolderPath As String
Dim wb As Workbook
'File Extension 'must contain wildcard "*" character
FileExtension = "*xls"
'Folder Path
FolderPath = "Y:\Financial Analyst\Metrics\Claims\"
FilesInFolder = Dir(FolderPath & FileExtension)
Application.ScreenUpdating = False
'Loop through each file in folder
Do While FilesInFolder <> ""
'Set variable to opened workbook
Set wb = Workbooks.Open(Filename:=FolderPath & FilesInFolder)
'Change First sheet Name to File Name
wb.Worksheets(1).Name = Left(wb.Name, Len(wb.Name) - Len(FileExtension) - 1)
'Close & Save
wb.Close True
'next file
FilesInFolder = Dir
Set wb = Nothing
Loop
Application.ScreenUpdating = True
End Sub
Code 2
Sub ammartino44()
Dim wbk As Workbook
Dim i As Long
For Each wbk In Workbooks
If wbk.Name <> "Master.xlsx" Then
wbk.Sheets(1).UsedRange.Copy Workbooks("Master.xlsx").Sheets("Master").Range("A" & Rows.Count).End(3)(2)
End If
Next wbk
End Sub
Bookmarks