Bug - Deleting custom number format used in conditional format corrupts Excel file and cannot save

Copper Contributor

I think I have found a bug in Excel that has existed for some time and still exists in current version of Excel 2019.  This can be easily reproduced in all recent versions off Excel, across versions of Windows.  I have attempted to report via technical MS support, but have been unable to get any traction.  Can anybody confirm this bug and duplicate?  If so, what is the best way to get this logged with Microsoft and get a fix in future versions?

 

Steps to recreate:

 

1) Open blank/new Excel workbook in Desktop App.  I happen to be using Excel build 13801.20808.

 

2) Pick a cell, for example, A1, right click, Format Cells, and then click custom

 

3) Create a new custom format.  For example, enter "A" (including quotes) as a sample format - the format doesn't really matter as long as it is a new custom format.  Click OK to save the custom format.

 

4) Note - After doing this, Excel creates 2 new custom formats that appear in the list of formats "after" the newly created one.  Go back into custom formats and create a "B" custom format so that the "B" custom format is last in the list.  Alternately, you can delete the two additional custom formats added by excel so yours is last in the list.

 

madsenkevin_1-1628168896681.png

 

5) Now, we are ready to corrupt the Excel document.

 

6) Enter some values, such as 1, 2, 3, 4, 5 in some cells.  Select one of the cells, such as the one with "2" in it.  

 

7) Create a conditional format using the custom format

     a) From the menu select Home, Conditional Formatting

     b) New Rule, Use a Formula to determine which cells to format

     c) for the formula enter "=2" (no quotes)

     d) click the format button, select Number tab

     e) select "Custom", then select the last custom format in the list

     f) Click Ok to apply conditional format

 

8)At this point, you should have a custom format that is last in the list of custom formats.  The custom format is used in a conditional format applied to a cell

 

9) To corrupt the worksheet, simply go to edit the custom formats, find your new custom format, and delete the custom format.

 

10) Try to save the document, you will get this error:

madsenkevin_2-1628169392190.png

 

At this point, your file is corrupt.  My experience is that even if you ask Excel to repair, the file will still be corrupt.

 

My diagnosis is this:

 

When applying conditional formats, the programming logic used in Excel uses an "index number" of the format used.  For example, In my spreadsheet, my custom format "B" was 40th in the list of custom formats.  When the conditional format was created, behind the scene, it says "use the 40th" custom format in the list.  If that 40th custom format is deleted, the conditional formatting still says "use the 40th" custom format.  BUT, it no longer exists after I have deleted.  Thus, it creates an error that cannot be handled and you cannot save the file.

 

This can be corrected - go back in and add a new "40th" custom format and all of a sudden you can save the file!

 

Even more interesting, if you use a conditional format for lets say the 20th custom format in the list and then delete the 10th custom format, the list "moves up".  What was the 21st custom format is now the 20th custom format.  The conditional format set does not change, resulting in the format using the NEW 20th custom number format.

 

The fix to this needs to include a routine such that if a custom number format is deleted, it needs to then automatically review all conditional formats that use that custom number format or any later in the list of custom number formats and update the "index" of which custom number format is being applied.

 

Hope this all makes sense and was described clearly.

 

Can anybody else reproduce this?  I have been able to reproduce this on any version of Excel 2019 and Windows 10 that I have tried.  I think this is a fundamental bug in Excel.

 

@Pernille-Eskebo- Can you log this as a bug and get it fixed?

8)Click the "Format buttom

 

 

4) 

 

 

2 Replies

Your best bet is to replicate the issue, write out everything you wrote in your message above into the spreadsheet, making sure all text and the screenshots are visible on the same window (no scrolling required) and then click File, Feedback, "I don't like something" and fill out the form, checking the screenshot box..

I have encountered the same issue. A file with some Visual Basic code in it the loads a few downloads of data, then pivots the data and creates an automated recon. It worked very well. Until…. I added some conditional formats at one point to make new “refunds” that had not yet been invoiced in our accounting system red, what a big mistake. I’ve tried everything, file corrupts after any save. I’ve even tried cutting and pasting each worksheet into a new file then taking the time to edit the pivot tables etc and it still corrupts. Microsoft won’t bother fixing this, they have other known issues they have ignored. Remember their earlier post on their developer website a couple years after they first released 64 bit office. They said, as a company, they had no intention of making a 64 bit version of Visual Basic that goes with office 64 bit, despite thousands of posts of people using VB in 64 bit office and complaining. If you had only 1 excel file open with VB then cb works ok. If you have 2 or more excel files with visual basic in them, open at the same time, and run the code in them, then save them, then windows will think the files are corrupt when you try to later re-open them. So office also creates endless serious issues for those that want to use automation code.

Excel is a badly needed product, and it has serious bugs that are openly ignored by management.