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

TheRedCardinal

Board Regular
Joined
Jul 11, 2019
Messages
143
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?
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,593
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Try running
VBA Code:
Sheet8.Sort.SortFields.Clear
and see if it clears the issue (please note that I am using the sheets codename)
 

TheRedCardinal

Board Regular
Joined
Jul 11, 2019
Messages
143
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!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
50,660
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,309
Messages
5,571,468
Members
412,395
Latest member
nielsvanlit
Top