password protect a worksheet

Billm

Board Regular
Joined
Mar 19, 2002
Messages
88
I want to make a spreadsheet available for say 30 days, then, after that time a messagebox appears notifying the user that the spreadsheet has expired ( and subsequently prevents them from opening it ) but then I still want to open it .. so can the messagebox then prompt for the same VBA password that protects all the code .. and if it is entered correctly .. opens the password as normal ?

Thanks
Bill
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try the following:
Code:
Private Sub Workbook_Open()
Dim StartDate As Date
StartDate = "04/16/2002"
If DateDiff("d", Now, StartDate) >= 30 Then PasswordCheck = InputBox("Password has expired, enter password")
If PasswordCheck <> "password" Then
Application.DisplayAlerts = False
ThisWorkbook.Close
End If
End Sub
 
Upvote 0
dont rely on Excel protection is aweful and stop advance user for about 3 1/2 seconds be for we rip it apart, but will keep out the non advanced user or about 5 seconds.

just to say so not relying on this to much easy hacked...
 
Upvote 0
I am confused. It seems the code above closes the workbook with no message appearing.

Am I doing something wrong?
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,222
Members
448,877
Latest member
gb24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top