My Macro has developed an error on start up - not file corruption

TheRedCardinal

Board Regular
Joined
Jul 11, 2019
Messages
243
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
The last couple of days the script that I am working on has developed an error when the workbook is loading.

Windows post a message saying

"We found a problem with some content in [My Workbook] - Do you want us to try to recover as much as we can."

When I click yes, the file opens and there is a report window which says:

"Removed Records: sorting from /xl/worksheets/sheet8.xml part"

There is one part of my macro which sorts a worksheet, but it is not sheet8.
Now sheet 8 is a hidden sheet which contains some data for the workbook.

This happened yesterday so I restarted my project afresh with new source documents and it has happened again.

Does anybody know what causes this error?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try running
VBA Code:
Sheet8.Sort.SortFields.Clear
and see if it clears the issue (please note that I am using the sheets codename)
 
Upvote 0
Try running
VBA Code:
Sheet8.Sort.SortFields.Clear
and see if it clears the issue (please note that I am using the sheets codename)

I actually did this anyway and it seems to have cleared the error - I did it within a "With WS1" block that the sort fields were part of (not sheet 8!). But it still worked.

I'm a little confused as to what's going on!
 
Upvote 0
Firstly sheet8.xml is the 8th sheet in the workbook, counting from left to right including hidden sheets
Secondly when using the SortFields.Add method of sorting, if you do not delete the existing sort, it just keeps adding new sort fields until there are too many & you then get problem you encountered.
So as Mark pointed out, you need to delete the existing sortfields, before adding any more.
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top