+ Reply to Thread
Results 1 to 4 of 4

Simple Code Fix for kill date

Hybrid View

ndickerson Simple Code Fix for kill date 08-06-2014, 08:29 AM
judgeh59 Re: Simple Code Fix for kill... 08-06-2014, 09:40 AM
ndickerson Re: Simple Code Fix for kill... 08-06-2014, 02:59 PM
judgeh59 Re: Simple Code Fix for kill... 08-06-2014, 03:01 PM
  1. #1
    Registered User
    Join Date
    08-05-2014
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS Office 2010
    Posts
    4

    Simple Code Fix for kill date

    This code is supposed to make it so that after a certain date (January 1st 2014 in this case) the file will ask for a password and if it is not the correct one it will exit. It seemed to run until i put the input box into the code when i debug it says there is not if associated with the last else.
    here is the code
    Private Sub Workbook_Open()
    If DateDiff("d", Date, #1/1/2014#) < -1 Then
    answer = InputBox("You need to contact the xxx branch of yyy to access the most up to date manual.", "Update Required")
        If answer = "rob" Then GoTo normalStart
        Else
        ThisWorkbook.Close Savechanges:=True
        End If
    Else
    GoTo normalStart
    End If
    normalStart:
        With Sheet1
            .Unprotect Password:="john"
           .Protect Password:="john", UserInterfaceOnly:=True
           .EnableOutlining = True
        End With
    End Sub
    If you can tell me whats wrong that would be great. thanks
    Last edited by ndickerson; 08-06-2014 at 03:01 PM.

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Simple Code Fix for kill date

    as goofy as it seems, just moving the GOTO on one of the IF statement lines seems to fix it....at least it didn't error when I tried....

    Private Sub Workbook_Open()
    
        If DateDiff("d", Date, #1/1/2014#) < -1 Then
            answer = InputBox("You need to contact the xxx branch of yyy to access the most up to date manual.", "Update Required")
            If answer = "rob" Then
                GoTo normalStart
            Else
                ThisWorkbook.Close Savechanges:=True
            End If
        Else
            GoTo normalStart
        End If
    
    normalStart:
        With Sheet1
            .Unprotect Password:="john"
           .Protect Password:="john", UserInterfaceOnly:=True
           .EnableOutlining = True
        End With
        
    End Sub
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Registered User
    Join Date
    08-05-2014
    Location
    Baltimore, Maryland
    MS-Off Ver
    MS Office 2010
    Posts
    4

    Re: Simple Code Fix for kill date

    Wow that worked.. I knew it would be something simple. Thanks a bunch

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Simple Code Fix for kill date

    no problem and thanks for the points....have a great day

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. simple date comparison - code review
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-11-2013, 06:33 PM
  2. Setting a time kill/delete by set date in spreadsheet
    By exempt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2011, 09:56 PM
  3. [SOLVED] Date Macro - Code Breaks - (Simple Macro)
    By aiwnjoo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2010, 05:36 AM
  4. Kill Worksheet Code
    By pr4t3ek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2008, 10:20 AM
  5. Kill a process - Could someone check this code for me
    By ina in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2006, 09:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1