PDA

View Full Version : Solved: Build workbook to match code



ndendrinos
11-12-2006, 07:08 AM
This code was offered by mdmackillop in another posting .
I've been trying to create the corresponding worbook to no avail.
Can anyone explain the configuration of the workbook in details ...
Thank you

Private Sub Workbook_Open()
Dim incRange As Range
Dim StartDate As Date

Set incRange = Range("Increment")
StartDate = "19/06/06" 'Date delivered to customer

Sheets("hidden").Visible = xlVeryHidden
incRange = incRange + 1
Me.Save
If incRange > 10 Or Date - StartDate > 14 Then
Application.DisplayAlerts = False
MsgBox "over the use limit, contact owner"
Me.Close
End If

End Sub

mdmackillop
11-12-2006, 07:30 AM
Here's a workbook incorporation the above code. You may need this to unhide the hidden sheet.

Sub unhide()
Dim sh As Worksheet
For Each sh In Worksheets
sh.Visible = True
Next
End Sub

ndendrinos
11-12-2006, 07:41 AM
Thank you ... In my next life if I'm born a girl , get married and have a child and the child turns up a boy I WILL NAME HIM AFTER YOU!!!
BTW: One of the many samples I built to get the thing working was introducing a new sheet named "hidden" instead or renaming Sheet1 ,,, don't see why it would bomb but I wll look into it.

ndendrinos
11-12-2006, 07:59 AM
Got it ... in my many samples i did not "name" the cell in "hidden" to "increment"