This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I used the following Macro to combine data from 3 files (Files 1, 2 and 3) into one Master file. Files 1, 2 and 3 will be files that are generated daily so I want to be able to update just the master file every day:
Sub filesToMain()
Dim fso, oFolder, oFile
Dim myWB As Workbook, oWB As Workbook
Set myWB = ThisWorkbook
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder("C:\Users\filepath")
For Each oFile In oFolder.Files
oRow = myWB.Sheets(1).UsedRange.Rows.Count 1
Set oWB = Workbooks.Open(oFile)
oWB.Sheets(1).Rows(1).Delete
oWB.Sheets(1).UsedRange.Copy myWB.Sheets(1).Cells(oRow, 1)
oWB.Close False
Next oFile
End Sub
Now, once this data has been appended to the master file, I want to automatically delete the data that is in files 1, 2 and 3, or actually delete the files themselves so that I do not accidentally duplicate the data.
Additionally, once the data has been copied from the master file, I want to automatically sort the rows in the master file chronologically. Column 1 will be date and multiple rows can have the same date.
Post Details
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/excel/comme...