Restrict execution of macros to only the original source workbook

  • Hi, how to stop users from running vba into the sheet in book1 when it is not thisworkbook macro.
    I mean, is there a way to stop users running macro into sheet1 of book1 from any other workbook?


    Thanks in advance for helping.

  • Re: How to stop users from running vba into the sheet in book1


    Are you asking if a macro could be written to not work if [forbiddenBook.xls]Sheet1! is active, then adding a line like this should do it.

    Code
    If ActiveWorkbook.Name = "forbiddenBook.xls" And ActiveSheet.Name = "Sheet1" Then Exit Sub


    If you want [forbiddenBook.xls]Sheet1! to be changed so that no macro can effect it, no that can't be done. The best you could do is very hide it so noone tries to do anything with it. (OR protect the workbook and worksheet so nothing can change.)

  • Re: How to stop users from running vba into the sheet in book1


    Hi Mike, thanks.
    it is 'no'. But i cant hide it for all users uses this sheet to update other sheet (sort of form sheet)...I dont know why there is a breaker code :) my mean concern is this sheet..because i do not want other users to change the information and manupulate the data....I tried locking up everything but still there is a way to break the password...

    PS: if i run this code from thisworkbook module as the book opens up will it stop from other macro running in this sheet?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!