I have an Excel file with a macro that filters records. After running the macro I save and close the file. Once I open the file again it says that the file has been corrupte
I'd comment this, simply providing the link, but I don't have 50 reputation yet.
A Google search turned up an SE thread from a few years ago with plenty of possible solutions: Excel Error: Removed Records: Sorting from /xl/worksheets/sheet10.xml part
Most likely to work is this one:
Sheets(yoursheetname).Sort.SortFields.Clear
Put that after your sort function (or before saving your file), and it seems the issue should be resolved.
Hopefully that works.