Excel 2010: Delete empty "Sheets" from VBA Project

Hi Everyone,

I've been doing some cleanup, and now have empty "Sheets" in Project Explorer that aren't associated to an Excel worksheet (they've been deleted). Also, there is no code on the "Sheets", either. I did have the code protected when I was deleting sheets.... could this be why they weren't removed from the VBA Project when the worksheets were deleted?

 I have run Rob Bovey's code cleaner, but it didn't resolve this. Does anyone know how to remove these ... just out of curiosity... the functionality hasn't been affected.
Here's a screenshot:
 C--Users-sscott-Pictures-ExcelProjExpl-E
Thanks so much,
Shelley
shelldeeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
On a standard module place the following code and run it to make sure that those sheets are not hidden.

Sub ShowSheets()
Dim ws As Worksheet
For Each ws In Worksheets
    ws.Visible = True
Next ws
End Sub

Open in new window

0
Roy CoxGroup Finance ManagerCommented:
have you tried closing Excel and re-opening?

Pritecting the code will not stop sheets being deleted.
0
shelldeeAuthor Commented:
Hi sktneer,

Thanks for responding :)

I ran your code -- and checked to see if any sheets showed up -- but they didn't. Was this to check if the visible property was set to xlSheetVeryHidden?

The thing that seems weird to me is that all of these sheets'/objects' icons have changed to the one that represents ThisWorkbook -- plus the codenames of all of the objects are also now "ThisWorkbook".

Thanks for your help!
Shelley
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

shelldeeAuthor Commented:
Hi Roy,

Yes I've tried closing and reopening a couple of times.

Thanks for your help,
Shelley
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
xlSheetVeryHidden will not matter, the code will make all the hidden sheets visible.

Create a backup file and then try the following code to see what happens in this case.

Sub DeleteEmptySheets()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In Worksheets
    If ws.Visible = xlSheetVeryHidden Then ws.Delete
Next ws
Application.DisplayAlerts = True
End Sub

Open in new window

0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You should try this as the above code may produce an error if the sheet is xlSheetVeryHidden....

Sub DeleteEmptySheets()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In Worksheets
    If ws.Visible = xlSheetVeryHidden Then
        ws.Visible = xlSheetVisible
        ws.Delete
    End If
Next ws
Application.DisplayAlerts = True
End Sub

Open in new window

0
shelldeeAuthor Commented:
Hi skteer,

I ran your code twice, the second time butting put a Debug.Print ws.CodeName before the IF statement to see if these "Sheets" were being checked in the loop. None of the "Sheets" in question were printed to the immediate window.

Thanks again,
Shelley
0
shelldeeAuthor Commented:
Hi again,

Re your second post -- I had already run similar code to this before posting to the forum (and also I did have some legitimate sheets set to very hidden, so I had already ran code to make everything visible.)

This seems like some sort of corruption, but it  isn't too big of a deal -- since I'm cleaning up anyways, I can just move everything to a new workbook. I was just curious if anyone else had run across this...

Thanks,
Shelley
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Yeah not a bad idea in case if nothing is working in favor.

But that's very strange because as far as I am aware if you see the sheets in the project explorer that means the sheets exist in the workbook.

Can you share the workbook after removing all the sensitive information from it, I am just curious to see the file.
If any issue uploading it here, you can PM me and attach your sample workbook.
0
shelldeeAuthor Commented:
Thanks for the offer sktneer! :)

Since i can't send any of the data, I'll move everything, and then send you what's left. I probably won't be able to have it ready until tonight sometime, tho -- since I need to do other work this afternoon.

Thanks again!
Shelley
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
No problem Shelley!

I think you should continue with what you have planned.


Regards.
0
shelldeeAuthor Commented:
Thanks -- sounds good -- and I'll repost when the file is ready to send.
Cheers :)
Shelley
0
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.