close

Hi

I need to create a password protected macro.

By this I don't mean the code (already done) but the ability to launch the
macro itself. I am sending a spreadsheet out and it has several macros
inbeded. I got one macro that I am the only one to use and needs to be
protected against others launching it. Any Ideas?

Chris, here is one way,

Sub PassWord_To_Run()
'must lock VBA project so you can't see the password in it
Dim MyStr1 As String, MyStr2 As String
With ActiveSheet
MyStr2 = (quot;123quot;) 'This is the password and it is CASE sensitive
MyStr1 = InputBox(quot;Password Is Required To Run this Macro quot;)
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox (quot;Access Deniedquot;)
End If
End With
End Sub--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 amp; 2003

quot;Chrisquot; gt; wrote in message
...
gt; Hi
gt;
gt; I need to create a password protected macro.
gt;
gt; By this I don't mean the code (already done) but the ability to launch the
gt; macro itself. I am sending a spreadsheet out and it has several macros
gt; inbeded. I got one macro that I am the only one to use and needs to be
gt; protected against others launching it. Any Ideas?
Perfect, exactly what I needed!

Thanks

quot;Paul Bquot; wrote:

gt; Chris, here is one way,
gt;
gt; Sub PassWord_To_Run()
gt; 'must lock VBA project so you can't see the password in it
gt; Dim MyStr1 As String, MyStr2 As String
gt; With ActiveSheet
gt; MyStr2 = (quot;123quot;) 'This is the password and it is CASE sensitive
gt; MyStr1 = InputBox(quot;Password Is Required To Run this Macro quot;)
gt; If MyStr1 = MyStr2 Then
gt;
gt; 'your code here
gt;
gt; Else
gt; MsgBox (quot;Access Deniedquot;)
gt; End If
gt; End With
gt; End Sub
gt;
gt;
gt; --
gt; Paul B
gt; Always backup your data before trying something new
gt; Please post any response to the newsgroups so others can benefit from it
gt; Feedback on answers is always appreciated!
gt; Using Excel 2002 amp; 2003
gt;
gt; quot;Chrisquot; gt; wrote in message
gt; ...
gt; gt; Hi
gt; gt;
gt; gt; I need to create a password protected macro.
gt; gt;
gt; gt; By this I don't mean the code (already done) but the ability to launch the
gt; gt; macro itself. I am sending a spreadsheet out and it has several macros
gt; gt; inbeded. I got one macro that I am the only one to use and needs to be
gt; gt; protected against others launching it. Any Ideas?
gt;
gt;
gt;

Your welcome, thanks for the feedback

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 amp; 2003

quot;Chrisquot; gt; wrote in message
...
gt; Perfect, exactly what I needed!
gt;
gt; Thanks
gt;
gt; quot;Paul Bquot; wrote:
gt;
gt; gt; Chris, here is one way,
gt; gt;
gt; gt; Sub PassWord_To_Run()
gt; gt; 'must lock VBA project so you can't see the password in it
gt; gt; Dim MyStr1 As String, MyStr2 As String
gt; gt; With ActiveSheet
gt; gt; MyStr2 = (quot;123quot;) 'This is the password and it is CASE sensitive
gt; gt; MyStr1 = InputBox(quot;Password Is Required To Run this Macro quot;)
gt; gt; If MyStr1 = MyStr2 Then
gt; gt;
gt; gt; 'your code here
gt; gt;
gt; gt; Else
gt; gt; MsgBox (quot;Access Deniedquot;)
gt; gt; End If
gt; gt; End With
gt; gt; End Sub
gt; gt;
gt; gt;
gt; gt; --
gt; gt; Paul B
gt; gt; Always backup your data before trying something new
gt; gt; Please post any response to the newsgroups so others can benefit from it
gt; gt; Feedback on answers is always appreciated!
gt; gt; Using Excel 2002 amp; 2003
gt; gt;
gt; gt; quot;Chrisquot; gt; wrote in message
gt; gt; ...
gt; gt; gt; Hi
gt; gt; gt;
gt; gt; gt; I need to create a password protected macro.
gt; gt; gt;
gt; gt; gt; By this I don't mean the code (already done) but the ability to launch
the
gt; gt; gt; macro itself. I am sending a spreadsheet out and it has several macros
gt; gt; gt; inbeded. I got one macro that I am the only one to use and needs to be
gt; gt; gt; protected against others launching it. Any Ideas?
gt; gt;
gt; gt;
gt; gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()