Prevent user from Deleting and Re-Arranging Worksheets using Excel VBA 2013

Anonymous
2014-02-04T17:56:03+00:00

Hi,

Is there a way in VBA to prevent the user from deliberately deleting or re-arranging worksheets using Excel VBA 2013 ? Obviously, I need to prevent users from trying to mess up with the application.

Can someone please help. I have found several ways by searching for these topics, suggesting several different approaches, all sound confusing and hard to understand. Please help!

Thank you.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2014-02-05T07:07:22+00:00

The code I supplied was not intended to go into a ThisWorkbook sheet, just a standard Module sheet as you've discovered.

When I referred to ThisWorkbook, I was referring to the code that read,

With ThisWorkbook

...

End With

, which might have to be changed to,

With ActiveWorkbook

...

End With

, or...

Set wb = Workbooks.open(<some workbook>)

With wb

...

End with

Was this answer helpful?

0 comments No comments

9 additional answers

Sort by: Most helpful
  1. Anonymous
    2014-02-05T01:33:24+00:00

    Hi Jeeped,

    Yes, this is what I need. How can I do this? Please suggest some leads in the code.

    Thank you.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-02-05T01:25:57+00:00

    You will want to protect the workbook structure. If you have to manipulate the structure within VBA, un-protect it with VBA, modify it and then re-protect it.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-02-05T01:16:01+00:00

    Hi Jim,

    You suggest protecting the whole workbook, but the workbook I am working on is macro enabled and thus some of the macros do not work properly under workbook protection. Is'nt there any other way through code to do this ?

    Appreciate your help.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-02-04T18:42:51+00:00

    Re: prevent sheets from being moved or deleted

    Protect the workbook.

    '---

    Jim Cone

    Portland, Oregon USA

    https://goo.gl/IUQUN2 (Dropbox)

    (free & commercial excel add-ins & workbooks)

    Was this answer helpful?

    0 comments No comments