ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   require password each time a macro is executed (https://www.excelbanter.com/excel-programming/313039-require-password-each-time-macro-executed.html)

Marty

require password each time a macro is executed
 
Workbook contains serveral worksheets with a number of macros. If the wrong
macro is executed for a given worksheet it will ruin the integrity of the
worksheet.
How do I avoid this problem other than using passwords.

Ivan F Moala[_19_]

require password each time a macro is executed
 

Workbook contains serveral worksheets with a number of macros. If th
wrong
macro is executed for a given worksheet it will ruin the integrity o
the
worksheet.
How do I avoid this problem other than using passwords.

Hi Marty
If you know which macro should by run in which sheet, then code it s
it checks the sheet before running. Post back if you requir
help.........in coding this ... but give details

--
Ivan F Moal

-----------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...nfo&userid=195
View this thread: http://www.excelforum.com/showthread.php?threadid=26785


bigwheel[_2_]

require password each time a macro is executed
 
Include a line in your code which checks that the required worksheet is
selected before the macro continues.

"Marty" wrote in message
...
Workbook contains serveral worksheets with a number of macros. If the

wrong
macro is executed for a given worksheet it will ruin the integrity of the
worksheet.
How do I avoid this problem other than using passwords.




Marty

require password each time a macro is executed
 
Thanks Ivan,
I understand but is this an if statement and how do you write it?
Marty

"Ivan F Moala" wrote:


Workbook contains serveral worksheets with a number of macros. If the
wrong
macro is executed for a given worksheet it will ruin the integrity of
the
worksheet.
How do I avoid this problem other than using passwords.

Hi Marty
If you know which macro should by run in which sheet, then code it so
it checks the sheet before running. Post back if you require
help.........in coding this ... but give details.


--
Ivan F Moala


------------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...fo&userid=1954
View this thread: http://www.excelforum.com/showthread...hreadid=267852



Marty

require password each time a macro is executed
 
Thanks Bigwheel,
I am rather new at this and understand your answere but have no idea how to
write it . Can you help?
Thanks again
Marty

"bigwheel" wrote:

Include a line in your code which checks that the required worksheet is
selected before the macro continues.

"Marty" wrote in message
...
Workbook contains serveral worksheets with a number of macros. If the

wrong
macro is executed for a given worksheet it will ruin the integrity of the
worksheet.
How do I avoid this problem other than using passwords.





Dave Peterson[_3_]

require password each time a macro is executed
 
If you can pick out something unique for that type of worksheet, then you can
test that to see if it's there.

For instance, if you have headers in A1:X1 and A1 always contains the text:
"Order Number"

you could put this at the top of your code:

sub testme()
if activesheet.range("a1").value < "Order Number" then
msgbox "Not on this sheet"
exit sub
end if
'your other code here
end sub

The question now becomes: Can you find something unique?


Marty wrote:

Thanks Bigwheel,
I am rather new at this and understand your answere but have no idea how to
write it . Can you help?
Thanks again
Marty

"bigwheel" wrote:

Include a line in your code which checks that the required worksheet is
selected before the macro continues.

"Marty" wrote in message
...
Workbook contains serveral worksheets with a number of macros. If the

wrong
macro is executed for a given worksheet it will ruin the integrity of the
worksheet.
How do I avoid this problem other than using passwords.





--

Dave Peterson


Tom Ogilvy

require password each time a macro is executed
 
Sub Macro1()

if lcase(Activesheet.Name) < "sheet1" then
msgbox "Sheet2 must be active to run this macro"
exit sub
End if

' existing code that works on the active sheet.

End Sub

"Marty" wrote in message
...
Thanks Ivan,
I understand but is this an if statement and how do you write it?
Marty

"Ivan F Moala" wrote:


Workbook contains serveral worksheets with a number of macros. If the
wrong
macro is executed for a given worksheet it will ruin the integrity of
the
worksheet.
How do I avoid this problem other than using passwords.

Hi Marty
If you know which macro should by run in which sheet, then code it so
it checks the sheet before running. Post back if you require
help.........in coding this ... but give details.


--
Ivan F Moala


------------------------------------------------------------------------
Ivan F Moala's Profile:

http://www.excelforum.com/member.php...fo&userid=1954
View this thread:

http://www.excelforum.com/showthread...hreadid=267852






All times are GMT +1. The time now is 03:42 PM.

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