View Single Post
  #5   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