View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Paul B Paul B is offline
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