Set expiry date 10 days from opening workbook

bptaw

Board Regular
Joined
Feb 27, 2017
Messages
69
Office Version
  1. 2016
Platform
  1. Windows
I currently have the following code in a user form:
Private Sub cmdLogin_Click()

Dim user As String
Dim password As String
user = Me.txtUserID.Value
password = Me.txtPassword.Value

If Date > DateValue("14-09-2023") Then
MsgBox "This Trial version has now expired and the Workbook will close."
ActiveWorkbook.Close SaveChanges:=False
Exit Sub

End If
If Date <= DateValue("14-09-2023") Then
MsgBox "This is a trial version and will expire on 14 September 2023."

End If

I want to change it so that the expiry date is 10 days from first opening the workbook. Anyone help?
 
You could password protect the code.
Also you could make HiddenSheet as xlVeryHidden in the code. This would make the sheet unable to be opened manually by Format>Unhide Sheet. It would have to be unhidden with code.
Could also (or instead) password protect the HiddenSheet.
 
Last edited:
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You could password protect the code.
Also you could make HiddenSheet as xlVeryHidden in the code. This would make the sheet unable to be opened manually by Format>Unhide Sheet. It would have to be unhidden with code.
Could also (or instead) password protect the HiddenSheet.
Yes, I made the sheet xlveryhidden and password protected the VBA so I'm happy with the result and have learnt a lot. Thanks
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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