Excel corruption with VBA sorting records

前端 未结 3 2026
死守一世寂寞
死守一世寂寞 2020-12-22 00:09

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

3条回答
  •  误落风尘
    2020-12-22 00:55

    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.

提交回复
热议问题