+ Reply to Thread
Results 1 to 14 of 14

Disable frames & option buttons on userform based on today's date

  1. #1
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Disable frames & option buttons on userform based on today's date

    Hi Experts

    I am new to VBA and wondering if this is possible to disable or lock the option buttons and the frames if today's date is greater than the date in a particular cell of a worksheet. I have a worksheet called "Raj" and in there a range A1 to A75 contains various dates in increasing order. Some dates repeat as well. e.g.
    ColoumnA ColoumnB

    A1 3-April-2013
    A2 4-April-2013
    A3 4-April-2013
    A4 5-April-2013
    A5....
    .
    .
    A75 26-May-2013

    In a userform1 I have around 75 frames and each frame has two option buttons. User is allowed to select or make any change in Ist frame only if today's date is less than 3rd of April 2013 otherwise the frame should be locked or disabled. Same will apply to the following frames, may be for loop or something like that is required.

    Also, is it possible to have the pre selected values restored on the userform when it is called again?

    I have done some searches around and have not found any solution to this so far. I would really appreciate your help in this.

    Regards
    Raj
    Last edited by raj.bris; 03-02-2013 at 01:07 AM. Reason: Closing Thread

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Disable frames & option buttons on userform based on today's date

    Raj ,
    You have not given anything for somebody to work with. How can anybody give you a decent answer?

  3. #3
    Registered User
    Join Date
    11-28-2005
    Location
    Saint Louis, Missouri USA
    MS-Off Ver
    2016
    Posts
    69

    Re: Disable frames & option buttons on userform based on today's date

    If I read this correctly, the first part is that you want to disable some userform controls (buttons) based on today's date meeting a criteria. The second part, you want the userform to have pre-loaded info.

    Assuming your userform is functional, after you load it but before you show it, just add If-Then code to compare the value in the cell for the April 3rd date to Now. If the current time (Now) is less than April 3rd then change the enabled property of the option button to true, else to false.

    You can also set a button to on, off or enabled at this point, or load a value into a text box before you show the userform.

    Hope that helps. I'm using my iPad, otherwise, I might have worked up an example.

  4. #4
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Disable frames & option buttons on userform based on today's date

    Sorry this was my first time ever asking for help online... please see the following code what I have come up with and working so far. I am not very happy with it.
    Also, I have changed a bit of cell referencing as well.

    A1 is R15 and today() = S15. I hope this makes sense.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Disable frames & option buttons on userform based on today's date

    Hi Evanzo

    Sorry to bother you again.

    I appreciate your quick response. I think I managed to do excatly what you suggested for locking of option buttons but just wondering how to use current time (now) in userform code.

    Cheers

  6. #6
    Registered User
    Join Date
    11-28-2005
    Location
    Saint Louis, Missouri USA
    MS-Off Ver
    2016
    Posts
    69

    Re: Disable frames & option buttons on userform based on today's date


  7. #7
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Disable frames & option buttons on userform based on today's date

    Hi -

    seems like this would work for you;
    Please Login or Register  to view this content.
    event

  8. #8
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Disable frames & option buttons on userform based on today's date

    Thanks Event. It worked pretty well and looks quite nice as well. just wondering if I can use now() rather than CDate() as I would like it to be based on time as well.
    Would it be too much to ask?
    Cheers

  9. #9
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Disable frames & option buttons on userform based on today's date

    Thanks Evanzo, I am looking into this now. looks like a pretty useful link.

  10. #10
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Disable frames & option buttons on userform based on today's date

    Hi -

    CDate includes time as well.

    event
    Quote Originally Posted by raj.bris View Post
    Thanks Event. It worked pretty well and looks quite nice as well. just wondering if I can use now() rather than CDate() as I would like it to be based on time as well.
    Would it be too much to ask?
    Cheers

  11. #11
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Disable frames & option buttons on userform based on today's date

    perfect... I just realised a second ago when I re-tested.
    Great Job Mate.

  12. #12
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Disable frames & option buttons on userform based on today's date

    hi mate.
    how do we close this thread?
    Cheers

  13. #13
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Disable frames & option buttons on userform based on today's date

    Hi -

    It's there.

    http://www.excelforum.com/faq.php

    event

  14. #14
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Disable frames & option buttons on userform based on today's date

    Thanks to everybody for all the help and guidance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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