+ Reply to Thread
Results 1 to 10 of 10

Program expired

Hybrid View

  1. #1
    Registered User
    Join Date
    08-23-2009
    Location
    seeb,oman
    MS-Off Ver
    Excel 2003
    Posts
    56

    Program expired

    Dear all,
    I created a workbook, which is presently running smoothly. The workbook is working with a macro, now i wanted to stop running the macro after a particular future date ( i.e. 26/06/2012) . Is it possible to give that as target date and after that the macro should not work and a message to appear as "program expired". If possible what will be the code to add in my macro.
    thanks and regards
    nowfal

  2. #2
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Program expired

    you can use something like this at the start of you sub:

    If Now() > #6/26/2012# Then
        MsgBox "Program Expired"
        Exit Sub
    End If
    Last edited by rkey; 05-23-2012 at 09:07 AM.

  3. #3
    Registered User
    Join Date
    08-23-2009
    Location
    seeb,oman
    MS-Off Ver
    Excel 2003
    Posts
    56

    Re: Program expired

    yes, it works, thanks alot

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Program expired

    or
    Sub Button1_Click()
    If Date <= #7/23/2012# Then
    [a2].ClearContents  'your code here
    Else
    MsgBox "Program expired!"
    End If
    End Sub
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  5. #5
    Registered User
    Join Date
    08-23-2009
    Location
    seeb,oman
    MS-Off Ver
    Excel 2003
    Posts
    56

    Re: Program expired

    sorry, mr rkey,
    it shows program expired in future date also. b coz i wanted to ruan the macro if i put future date. another problem complie error : end if without block if
    please look into the matter

  6. #6
    Registered User
    Join Date
    08-23-2009
    Location
    seeb,oman
    MS-Off Ver
    Excel 2003
    Posts
    56

    Re: Program expired

    yes, with mr.john's code , i got the solution. i have tested with both dates
    thanks to both of you.
    with regards
    nowfal

  7. #7
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Program expired

    You are right, had to cut of the time :P

    sub test
    If Format(Now(), "mm/dd/yyyy") > #6/26/2012# Then
        MsgBox "Program Expired"
        Exit Sub
    End If
    
    'your code here
    
    end sub
    The end if error is caused by the if statement. Please check all open and closes of the if statement.

  8. #8
    Registered User
    Join Date
    08-23-2009
    Location
    seeb,oman
    MS-Off Ver
    Excel 2003
    Posts
    56

    Re: Program expired

    mr.rkey, thanks for your help. One more question, is it possible i can give access with another message box providing some password or access code. just for the curiosity to learn things
    thanks and regards
    nowfal

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Program expired

    Format is unnecessary

    Option Explicit
    
    
    Sub Expired()
        If Date > CDate("26/05/2012") Then
            MsgBox "Workbook expired", vbCritical, "Expired"
        End If
    End Sub
    Attached Files Attached Files
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  10. #10
    Registered User
    Join Date
    08-23-2009
    Location
    seeb,oman
    MS-Off Ver
    Excel 2003
    Posts
    56

    Re: Program expired

    Mr.royuk, thanks for the information.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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