I have several Excel files in a folder that I need to be formatted, and then the resultant files merged into one master spreadsheet.
1. I have the code to open all the files in the specified folder as follows:
Sub Open_Workbooks()
Dim myPath As String
Dim myFile As String
Dim wb As Workbook
' Specify the folder path containing the Excel files
myPath = "C:UsersKudaDocumentsTRIAL BALANCES"
' Check for trailing backslash in folder path
If Right(myPath, 1) <> "" Then myPath = myPath & ""
' Find the first Excel file in the folder
myFile = Dir(myPath & "*.xls*")
' Loop through all Excel files in the folder
Do While myFile <> ""
' Open the workbook
Set wb = Workbooks.Open(myPath & myFile)
' Move to the next file (this line is essential to avoid an endless loop)
myFile = Dir
Loop
End Sub
2. The formatting code will be:
Call tb_cleanup()
3. Now I need a 3rd code that applies code #2 to all the open spreadsheets, and then copies the formatted data from each open spreadsheet, and then pastes it, stacking them one after the other onto one master spreadsheet.
#4 The Fourth code would be one singular code which has the above 3 all in one.