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: Newest
  1. Anonymous
    2014-02-05T17:07:56+00:00

    I'm glad to hear you got sorted out. Thanks for taking the time to follow up with the positive feedback and your kind words.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-02-05T12:41:57+00:00

    Hi Jeeped,

    Apologies, if I've missed the point, but I got the idea in the end, which is the important thing.

    Thank you for explaining, it now works perfectly for me !!!

    Greatly appreciate your help.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-02-05T07:06:21+00:00

    Hi Jeeped,

    Thanks for the quick reply. However, VBA flashes an error "Compile Error: Constants, Fixed-Length Strings, Arrays, User-Defined Types and Declared Statements not allowed as Public Members Object Modules" and the very first line of code:

    Public Const csPASSWORD As String = "my_p_word" goes RED as soon as cursor goes on the next line.

    This happens as I put the code into the ThisWorkbook.  But as I put this code into one of the modules, it gives no such error. It does not work on the ThisWorkbook structure.

    Hi Maneesh,

    Jeeped's suggested code should be placed in a standard code module -  not a worksheet module and not  the ThisWorkbook module.

    ===

    Regards,

    Norman

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-02-05T06:47:42+00:00

    Hi Jeeped,

    Thanks for the quick reply. However, VBA flashes an error "Compile Error: Constants, Fixed-Length Strings, Arrays, User-Defined Types and Declared Statements not allowed as Public Members Object Modules" and the very first line of code:

    Public Const csPASSWORD As String = "my_p_word" goes RED as soon as cursor goes on the next line.

    This happens as I put the code into the ThisWorkbook.  But as I put this code into one of the modules, it gives no such error. It does not work on the ThisWorkbook structure.

    Was this answer helpful?

    0 comments No comments