MrExcel
.
- Joined
- Feb 8, 2002
- Messages
- 3,428
- Office Version
- 365
- Platform
- Windows
I ran into a bizarre worksheet problem yesterday. We've figured out the "why" and so I am posting this to document one problem, but I am also looking for solutions to figure out the "what to do about it".
1. I found a workbook with many worksheets.
One 1 worksheet there were two cells with validation that were set to display the in-cell dropdown. Neither would display the in cell dropdown.
2. If I added a new validation to this sheet, it would not display the dropdown.
3. If I added a new validation to another sheet, the dropdown displayed and it worked perfectly.
4. In the problem sheet, the validation rules do work. If I try to enter something not in the list, I do get the error box, so the logic for the validation is working.
This problem has been discussed many times on this board. As many have posted, validation above the freeze panes row would not work in Excel 97. Sometimes the validation list range gets corrupted. None of this was the issue on this worksheet.
I now know how it happens. You can easily duplicate this yourself:
A. Open a new workbook with 2 worksheets
B. Add validation to a cell on each worksheet. Specify a list, in-cell dropdown.
C. With sheet1 active, go to the VBA immediate window. Run this code:
For Each obj in ActiveSheet.Shapes
bj.Delete:Next
D. None of the validation dropdowns on Sheet1 work anymore. All future dropdowns will not work on that sheet.
When I started writing VBA, I would use that line of code a lot. It is a fairly evil line of code. If you insert some cell comments on a worksheet and run that code, it will permanently corrupt the worksheet. As soon as you get near the red triangle in the commented cell, Excel will GPF and crash. I quit using that logic to avoid the cell comment problem, but it obviously causes the dropdown problem as well.
Long build-up to the question: Is there any way to repair the sheet once this has been done?
Our not-so-elegant workaround was to insert a blank worksheet, cut all the cells from the damaged sheet and paste them to the new sheet. This isn't perfect, because you lose column widths and row heights.
Any thoughts would be appreciated.
Bill
1. I found a workbook with many worksheets.
One 1 worksheet there were two cells with validation that were set to display the in-cell dropdown. Neither would display the in cell dropdown.
2. If I added a new validation to this sheet, it would not display the dropdown.
3. If I added a new validation to another sheet, the dropdown displayed and it worked perfectly.
4. In the problem sheet, the validation rules do work. If I try to enter something not in the list, I do get the error box, so the logic for the validation is working.
This problem has been discussed many times on this board. As many have posted, validation above the freeze panes row would not work in Excel 97. Sometimes the validation list range gets corrupted. None of this was the issue on this worksheet.
I now know how it happens. You can easily duplicate this yourself:
A. Open a new workbook with 2 worksheets
B. Add validation to a cell on each worksheet. Specify a list, in-cell dropdown.
C. With sheet1 active, go to the VBA immediate window. Run this code:
For Each obj in ActiveSheet.Shapes

D. None of the validation dropdowns on Sheet1 work anymore. All future dropdowns will not work on that sheet.
When I started writing VBA, I would use that line of code a lot. It is a fairly evil line of code. If you insert some cell comments on a worksheet and run that code, it will permanently corrupt the worksheet. As soon as you get near the red triangle in the commented cell, Excel will GPF and crash. I quit using that logic to avoid the cell comment problem, but it obviously causes the dropdown problem as well.
Long build-up to the question: Is there any way to repair the sheet once this has been done?
Our not-so-elegant workaround was to insert a blank worksheet, cut all the cells from the damaged sheet and paste them to the new sheet. This isn't perfect, because you lose column widths and row heights.
Any thoughts would be appreciated.
Bill