Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

11
I have a macro to combine data from 3 Excel files and combine into one master file. How do I get it to delete the data from the original files or delete the files themselves? Also, after appending, I want the data to be sorted chronologically
Post Flair (click to view more posts with a particular flair)
Post Body

Follow up to this thread

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.

Author
Account Strength
50%
Account Age
8 years
Verified Email
No
Verified Flair
No
Total Karma
103
Link Karma
81
Comment Karma
22
Profile updated: 3 days ago
Posts updated: 11 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
8 years ago