Corruption?

M

Mike Preston

Can I assume that if I abend when running the following public
function that I have some form of corruption in my workbook? If so,
any suggestions as to the best way to create a workbook without
corruption?

Public Function ShowItAll() as Boolean

For i = 1 To Worksheets.Count
Sheets(i).Visible = True
Next i
ShowItAll = True
End Function

The line "Sheets(i).Visible = True" consistently gives me an error
that Excel needs to shut down after the 9th and before the 10th
worksheet in the workbook is set to visible.

Thanks

mike
 
T

Tom Ogilvy

Since you are unhiding sheets and it fails on the same sheet each time (the
10th sheet), then it might be an indication there is some corruption in your
workbook. You might try skipping over the 10th sheet and unhide the rest,
then copy them to a new workbook and create a new 10th sheet.

Public Function ShowItAll() as Boolean
For i = 1 To Worksheets.Count
if i <> 10 then _
Sheets(i).Visible = True
Next i
ShowItAll = True
End Function

Regards,
Tom Ogilvy
 
M

Mike Preston

I would also change your code to prevent possible problems with dialog
sheets and chart sheets etc: currently you are using the count of the
worksheets collection (worksheets only) but referring to the sheets
collection (all types of sheet).

Good point, although making them consistent doesn't change the abend.

mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top