ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to disable a macro (https://www.excelbanter.com/excel-programming/283901-how-disable-macro.html)

Jeff Smith[_2_]

How to disable a macro
 
I have a spreadsheet virtrually entirely run by macros activated by control
box buttons.

There is a dialog of User name and Password and if there is a match the user
name and position is shown in cells Main!D11 and D12 (respectiviely). The
user name is "picked-up " and added to all printed reports.

I would like to disable the macro if the UserName is "Unauthorised User".

I was wondering if I could insert - at the start of each macro , prior to
the controlled actions, something like....

If Main!D12 = "Unauthorised User" End Sub

I plan to paste the routine prior to all macros.

Can anyone help me here please?

Thanks in anticipation,

sincerely

Jeff Smith



Bill Manville

How to disable a macro
 
Jeff Smith wrote:
I was wondering if I could insert - at the start of each macro , prior to
the controlled actions, something like....

If Main!D12 = "Unauthorised User" End Sub


If Sheets("Main").Range("D12") = "Unauthorised User" Then Exit Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup


Jeff Smith[_3_]

How to disable a macro
 
Thank you very much for this. This works well.

sincerely

Jeff Smith


"Bill Manville" wrote in message
...
Jeff Smith wrote:
I was wondering if I could insert - at the start of each macro , prior

to
the controlled actions, something like....

If Main!D12 = "Unauthorised User" End Sub


If Sheets("Main").Range("D12") = "Unauthorised User" Then Exit Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup





All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com