Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Code that ask user for a password before it runs..

Hi,

I'm using this code below to delete some unused worksheets in the active
workbook.
I only want certain users to be able to use this feature..
so..
Is there a way to add code to this code below...that would ask the user for
a password....maybe in a userform ...and then if they type in the correct
password, the code below runs..and if they type in an incorrect
password..this code does not run.


Sub DeleteBlankSheets()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub

Any help is greatly appreciated!!
Thanks in advance,
Kimberly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Code that ask user for a password before it runs..

Kimberly, try this, you must lock VBA project so you can't see the password
in it


Sub DeleteBlankSheets()

Dim sht As Worksheet
Dim MyStr1 As String, MyStr2 As String
MyStr2 = ("123") '*****This is the password
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next
Else
MsgBox ("Access Denied")
End If
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 & 2003

"KimberlyC" wrote in message
...
Hi,

I'm using this code below to delete some unused worksheets in the active
workbook.
I only want certain users to be able to use this feature..
so..
Is there a way to add code to this code below...that would ask the user

for
a password....maybe in a userform ...and then if they type in the correct
password, the code below runs..and if they type in an incorrect
password..this code does not run.


Sub DeleteBlankSheets()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub

Any help is greatly appreciated!!
Thanks in advance,
Kimberly




  #3   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Code that ask user for a password before it runs..

Sub DeleteBlankSheets()
Dim sht As Worksheet
dim ans as string
dim password as string

password = "pumpkin123"

ins = inputbox ( "PLEASE ENTER PASSWORD")
if ans is < " pumpkin123" then end


For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub




"KimberlyC" wrote in message
...
Hi,

I'm using this code below to delete some unused worksheets in the active
workbook.
I only want certain users to be able to use this feature..
so..
Is there a way to add code to this code below...that would ask the user
for
a password....maybe in a userform ...and then if they type in the correct
password, the code below runs..and if they type in an incorrect
password..this code does not run.


Sub DeleteBlankSheets()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub

Any help is greatly appreciated!!
Thanks in advance,
Kimberly




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Code that ask user for a password before it runs..

And you can do something similar with a user form with a text box.

Except you can make the fore (font) color and back color both white, or
black, or ....
so that no one can see what is being typed.

Used to know how to make the font appear as *****, but can't find my
reference
maybe some one else can remember how to do that...

--
steveB

Remove "AYN" from email to respond
"N10" wrote in message
...
Sub DeleteBlankSheets()
Dim sht As Worksheet
dim ans as string
dim password as string

password = "pumpkin123"

ins = inputbox ( "PLEASE ENTER PASSWORD")
if ans is < " pumpkin123" then end


For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub




"KimberlyC" wrote in message
...
Hi,

I'm using this code below to delete some unused worksheets in the active
workbook.
I only want certain users to be able to use this feature..
so..
Is there a way to add code to this code below...that would ask the user
for
a password....maybe in a userform ...and then if they type in the correct
password, the code below runs..and if they type in an incorrect
password..this code does not run.


Sub DeleteBlankSheets()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub

Any help is greatly appreciated!!
Thanks in advance,
Kimberly






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Code that ask user for a password before it runs..

"STEVE BELL" wrote in message
news:ztYAe.12025$Ll6.9792@trnddc06...

And you can do something similar with a user form with a text box.

Except you can make the fore (font) color and back color both white,
or black, or ....
so that no one can see what is being typed.

Used to know how to make the font appear as *****, but can't find my
reference
maybe some one else can remember how to do that...

--
steveB


One way would be to dynamically replace the password as it is typed
with actual * symbols.

You'd have to store the password in a variable I guess.

I suspect the screen would flicker annoyingly too.

Just an idea.

Alan.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Code that ask user for a password before it runs..

To add to this (and answer Steve's ponderence):

If you set the PasswordChar property of the TextBox to "*", for example,
it will mask out the text they type - just like a grownup program!

e.g. TextBox1.Passwordchar = "*"



STEVE BELL wrote:
And you can do something similar with a user form with a text box.

Except you can make the fore (font) color and back color both white, or
black, or ....
so that no one can see what is being typed.

Used to know how to make the font appear as *****, but can't find my
reference
maybe some one else can remember how to do that...

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Code that ask user for a password before it runs..

Gareth,

Thank you very much! Knew it was there (someplace) but didn't think of
looking at Properties.... (duh, me)

--
steveB

Remove "AYN" from email to respond
"Gareth" wrote in message
...
To add to this (and answer Steve's ponderence):

If you set the PasswordChar property of the TextBox to "*", for example,
it will mask out the text they type - just like a grownup program!

e.g. TextBox1.Passwordchar = "*"



STEVE BELL wrote:
And you can do something similar with a user form with a text box.

Except you can make the fore (font) color and back color both white, or
black, or ....
so that no one can see what is being typed.

Used to know how to make the font appear as *****, but can't find my
reference
maybe some one else can remember how to do that...



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Code that ask user for a password before it runs..

"Alan" wrote in message
...

One way would be to dynamically replace the password as it is typed
with actual * symbols.

You'd have to store the password in a variable I guess.

I suspect the screen would flicker annoyingly too.

Just an idea.

Alan.


Scrap that - use Gareth's way!

See he

...

Alan.



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Code that ask user for a password before it runs..

This worked well...
Thank you!!!
"Paul B" wrote in message
...
Kimberly, try this, you must lock VBA project so you can't see the

password
in it


Sub DeleteBlankSheets()

Dim sht As Worksheet
Dim MyStr1 As String, MyStr2 As String
MyStr2 = ("123") '*****This is the password
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next
Else
MsgBox ("Access Denied")
End If
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 & 2003

"KimberlyC" wrote in message
...
Hi,

I'm using this code below to delete some unused worksheets in the active
workbook.
I only want certain users to be able to use this feature..
so..
Is there a way to add code to this code below...that would ask the user

for
a password....maybe in a userform ...and then if they type in the

correct
password, the code below runs..and if they type in an incorrect
password..this code does not run.


Sub DeleteBlankSheets()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub

Any help is greatly appreciated!!
Thanks in advance,
Kimberly






  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Code that ask user for a password before it runs..

Thank you all for your help!!
I will try the userform method as well..
I like the ****
:)
"KimberlyC" wrote in message
...
Hi,

I'm using this code below to delete some unused worksheets in the active
workbook.
I only want certain users to be able to use this feature..
so..
Is there a way to add code to this code below...that would ask the user

for
a password....maybe in a userform ...and then if they type in the correct
password, the code below runs..and if they type in an incorrect
password..this code does not run.


Sub DeleteBlankSheets()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub

Any help is greatly appreciated!!
Thanks in advance,
Kimberly






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Code that ask user for a password before it runs..

Your welcome

--
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 & 2003

"KimberlyC" wrote in message
...
This worked well...
Thank you!!!
"Paul B" wrote in message
...
Kimberly, try this, you must lock VBA project so you can't see the

password
in it


Sub DeleteBlankSheets()

Dim sht As Worksheet
Dim MyStr1 As String, MyStr2 As String
MyStr2 = ("123") '*****This is the password
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next
Else
MsgBox ("Access Denied")
End If
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 & 2003

"KimberlyC" wrote in message
...
Hi,

I'm using this code below to delete some unused worksheets in the

active
workbook.
I only want certain users to be able to use this feature..
so..
Is there a way to add code to this code below...that would ask the

user
for
a password....maybe in a userform ...and then if they type in the

correct
password, the code below runs..and if they type in an incorrect
password..this code does not run.


Sub DeleteBlankSheets()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets
If sht.Range("A3") = "Delete" Then
Application.DisplayAlerts = False
sht.Delete
Application.DisplayAlerts = True
End If

Next

End Sub

Any help is greatly appreciated!!
Thanks in advance,
Kimberly








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
Cerfiticate Issues When User runs my Macro Jenny B. Excel Discussion (Misc queries) 0 January 18th 08 01:24 AM
Password visible if user selects "view code" kcdonaldson Excel Worksheet Functions 2 December 3rd 05 03:48 PM
User to decide how often a macro runs Deedee Excel Discussion (Misc queries) 2 November 2nd 05 08:42 PM
Links in formulas change when another user runs a workbook L Mehl Excel Discussion (Misc queries) 2 November 27th 04 09:27 PM
Show progress in a user form while code runs Bura Tino Excel Programming 2 April 15th 04 06:18 AM


All times are GMT +1. The time now is 11:00 PM.

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

About Us

"It's about Microsoft Excel"