+ Reply to Thread
Results 1 to 4 of 4

Determine if Commandbutton is clicked

  1. #1
    Forum Contributor
    Join Date
    02-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    367

    Determine if Commandbutton is clicked

    Hi,

    Can anyone help me with my problem.
    I have a userform with commandbutton. I just want when the userform initialize and if the pc time is 9:00 PM and the commandbutton is
    unclicked, msgbox will display "Unclicked" else do nothing.

    Something like this, but i can't get the right syntax:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Determine if Commandbutton is clicked

    The command button do not store it's status (it is clicked only during clicking action). Moreover you say about UF initialize.
    So you shall store somewhere (static variable, external file, hidden cell, etc.) info that the button has been clicked and then use this stored info in initialization.
    Think when to mark this variable as "unclicked" - may be just after your if-end if command. and of course include in your CommandButton1_Click proc setting this variable as clicked.
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    02-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    367

    Re: Determine if Commandbutton is clicked

    I see. Thanks Kalper.

    I've ended with this.

    Please Login or Register  to view this content.
    So what's the syntax for the time?
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Determine if Commandbutton is clicked

    So:

    Please Login or Register  to view this content.
    But note that (not tested) in my opinion txtbox1 value will be always "" while you do Initialize. I think that info about clicking shall be stored outside code of Userform.

+ 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. Commandbutton in userform to execute code based on a previous commandbutton choice?
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2012, 03:28 PM
  2. Determine if the close button in excel 2007 is clicked
    By Hudas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-17-2012, 10:43 AM
  3. Determine if cell was clicked or cursored to
    By excelbobabc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2010, 04:23 PM
  4. Determine when checkbox is clicked
    By wAyne in forum Excel General
    Replies: 1
    Last Post: 02-21-2006, 04:40 PM
  5. [SOLVED] Determine last clicked object / control
    By Rex in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2005, 02:05 PM

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