Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Macro button that asks for password before proceeding?

Is there a way to stop the user and have the prompted to enter a password
before this macro button is run? I was this to only be an option for
Administrative purposes only.

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Macro button that asks for password before proceeding?


Sub Macro()

Dim strPassword As String
Do While Trim(strPassword) = ""
strPassword = Trim(InputBox("Enter Password"))
Loop

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Munchkin" wrote:

Is there a way to stop the user and have the prompted to enter a password
before this macro button is run? I was this to only be an option for
Administrative purposes only.

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Macro button that asks for password before proceeding?

How & where do I specify what the password is? I tried entering the password
inside the quotation marks, but it didn't work.

"Jacob Skaria" wrote:


Sub Macro()

Dim strPassword As String
Do While Trim(strPassword) = ""
strPassword = Trim(InputBox("Enter Password"))
Loop

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Munchkin" wrote:

Is there a way to stop the user and have the prompted to enter a password
before this macro button is run? I was this to only be an option for
Administrative purposes only.

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Macro button that asks for password before proceeding?

Try the below...password is ........ mypassword

Sub Macro()

Dim strPassword As String
Do While Trim(strPassword) < "mypassword"
strPassword = Trim(InputBox("Enter Password"))
Loop

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Munchkin" wrote:

How & where do I specify what the password is? I tried entering the password
inside the quotation marks, but it didn't work.

"Jacob Skaria" wrote:


Sub Macro()

Dim strPassword As String
Do While Trim(strPassword) = ""
strPassword = Trim(InputBox("Enter Password"))
Loop

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Munchkin" wrote:

Is there a way to stop the user and have the prompted to enter a password
before this macro button is run? I was this to only be an option for
Administrative purposes only.

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Macro button that asks for password before proceeding?

It works! Thanks so much. Now - for another question. I tested it to see
what happens if you enter the wrong password and it seems to be stuck in
limbo until you enter the correct password. How do I get the cancel button
to end the macro?

"Munchkin" wrote:

Is there a way to stop the user and have the prompted to enter a password
before this macro button is run? I was this to only be an option for
Administrative purposes only.

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Macro button that asks for password before proceeding?

Dim varPassword As Variant
varPassword = Trim(InputBox("Enter Password"))
If Trim(varPassword) < "mypassword" Then Exit Sub

If this post helps click Yes
---------------
Jacob Skaria


"Munchkin" wrote:

It works! Thanks so much. Now - for another question. I tested it to see
what happens if you enter the wrong password and it seems to be stuck in
limbo until you enter the correct password. How do I get the cancel button
to end the macro?

"Munchkin" wrote:

Is there a way to stop the user and have the prompted to enter a password
before this macro button is run? I was this to only be an option for
Administrative purposes only.

Sheets("POLICY LIST").Select
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Rows("2:6").Select
Selection.EntireRow.Hidden = True
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro button that asks for password before proceeding?

On Aug 5, 12:43*pm, Jacob Skaria
wrote:
Dim varPassword As Variant
varPassword = Trim(InputBox("Enter Password"))
If Trim(varPassword) < "mypassword" Then Exit Sub

If this post helps click Yes
---------------
Jacob Skaria



"Munchkin" wrote:
It works! *Thanks so much. *Now - for another question. *I tested it to see
what happens if you enter the wrong password and it seems to be stuck in
limbo until you enter the correct password. *How do I get the cancel button
to end the macro?


"Munchkin" wrote:


Is there a way to stop the user and have the prompted to enter a password
before this macro button is run? *I was this to only be an option for
Administrative purposes only.


* Sheets("POLICY LIST").Select
* * Rows("1:1").Select
* * Selection.EntireRow.Hidden = False
* * Rows("2:6").Select
* * Selection.EntireRow.Hidden = True
End Sub


you could also put a conditional loop that gives back a message as in


do while...

if varpasswors<"mypassword" then
msgbox("password incorrect")
end if

loop


if you don't want to loop you could just write:

varpw=trim(inputbox("pw please"))

if strcomp(varpw ,"mypassword",vbTextCompare) <0 then

Workbooks("Your WB").Close SaveChanges:=False
else

your code...

end if


avoids the do while loop which is sometimes a little glitchy for some.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
link from web page to excel asks for username and password BC Excel Discussion (Misc queries) 0 October 18th 09 04:40 PM
link to workbook from web page asks for username and password BC Excel Discussion (Misc queries) 0 October 16th 09 03:56 PM
Excel asks for addin password on exit Karl Excel Programming 2 November 21st 04 12:17 PM
Macro that asks for password Jonsson Excel Programming 0 October 8th 03 12:11 PM
Web Folders - Excel file -- asks for password again Chris Knight Excel Programming 0 September 6th 03 12:02 AM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"