Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Worksheet Expiration

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian C - 20 Jan 2006 20:35 GMT
Hi,
I want to set an expiration date for a worksheet.  I'll store the date in an
xlveryhidden sheet in a cell.

Can someone help with the code to check the cell and compare to now, and
goto a sub to hide the other sheets?

Thanks,

Brian
Leith Ross - 20 Jan 2006 21:43 GMT
Hello Brian,

This macro should get you going. Just change the Worksheet name to
match the name of your "Very hiddden Worksheet" and cell "A1" to cell
that will hold your expiration date. Set the variable "UsableDays" to
the number of days that can pass before the worksheet expires.

'<Start Macro Code>
Sub CheckExpiration()

Dim DaysElapsed
Dim ExpirationDate
Dim HiddenSheet As Worksheet
Dim UsableDays
Dim Wks

UsableDays = 30
Set HiddenSheet = Worksheets("Sheet3")
ExpirationDate = HiddenSheet.Range("A1").Value

DaysElapsed = Int(Now) - Int(ExpirationDate)

If DaysElapsed >= UsableDays Then
For Each Wks In Worksheets
If Wks.Name <> HiddenSheet.Name Then
Wks.Visible = False
End If
Next Wks
End If

End Sub
'<End Macro Code>

Sincerely,
Leith Ross

Signature

Leith Ross

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.