+ Reply to Thread
Results 1 to 10 of 10

Command button do not activate until changing cell.

  1. #1
    Registered User
    Join Date
    08-22-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    4

    Command button do not activate until changing cell.

    Hi all,

    this is my first post to the forum

    I have a small problem with my command button in excel.

    A short description of my program would be I made a form with a save button that opens up another excelbook and save some data from the form in the other book and then closes the other book. I put all the code in the buttons "on click" part.

    The problem is that the users cannot click on the button (totally unclickable) if they have an active cell where they wrote something in.

    The workaround is simply to click in a new cell (then the button works fine) but if you start to type anything in the new cell the button becomes unclickable again.

    The problem is not everyone that will use the program have the time/patience to click in a new cell before pushing the button so I guess Im looking for something like
    button on mouse over get focus or something but I cant get it to work.. could someone please enlighten me

    Thanks

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Command button do not activate until changing cell.

    You can try a workaround like:
    Please Login or Register  to view this content.
    So when a user presses enter or tab after entering in the cell, it would be equivalent to clicking the button. You may want to also check if the Target is within a specified range where the user would enter data in.

  3. #3
    Registered User
    Join Date
    08-22-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Command button do not activate until changing cell.

    Hello,

    wouldn't that execute the button every time someone hit enter? (this would be a problem since the spreadsheet is a report and by clicking the button it opens up a summary page and adds the values from the form, sends some emails and then clears the form before closing it). Anyway if i hit tab the button becomes unstuck anyway. It is just if i start to write into a cell and then tries to click the button then the button is inactive (because it is the current cell where im typing things into that is active (like the cell is waiting for more input and thereby locks the control).

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Command button do not activate until changing cell.

    I think millz meant that to be Worksheet_SelectChange. As it is now, every time you press a key it would click the button. Maybe:
    Please Login or Register  to view this content.
    But it would have to me an activeX button.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  5. #5
    Registered User
    Join Date
    08-22-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Command button do not activate until changing cell.

    Hi and thanks.

    So there is no way to do this for a standard button (not activeX)?

    I was thinking in the excelsheet if I could put some code in a onmousemove or something to shift focus to the button from the cell.. any ideas?

    Also is there a way to run VBA code (like a button like this) even for users that doesnt allow macros? (I'm doing this in my company and I would not really like to turn off the protection for all computers... Or atleast is there a way to code so instead of the yellow warning on top of the sheet asking to run the macro would it be possible to have a msg box come up and ask if they would like to allow macros? (not everyone here is good with computers and to instruct them how to turn on macroactivation would be tough heh

  6. #6
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: Command button do not activate until changing cell.

    Hi,
    perhaps something like this for the second problem, you can try Ken's idea
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=379
    blue

  7. #7
    Registered User
    Join Date
    08-22-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Command button do not activate until changing cell.

    Hmm yeah seems like a good way to fix problem no. 2. Thanks

  8. #8
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: Command button do not activate until changing cell.

    Thank you for the feedback and rep. hope it 'll help you!

  9. #9
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Command button do not activate until changing cell.

    No, standard buttons don't have events, and there isn't a Mouse_Move event for a worksheet.

  10. #10
    Forum Contributor
    Join Date
    03-14-2012
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    170

    Re: Command button do not activate until changing cell.

    XeRo Solus, I tried in the past to do something similar with a form control (button) and I did not find anything to work, I used an activex as you also posted.

+ 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. Activate 2 dropdowns with one command button
    By smoot123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-22-2012, 10:10 PM
  2. [SOLVED] Changing ODBC command texts and refreshing via command button
    By milty456 in forum Excel General
    Replies: 2
    Last Post: 10-09-2012, 12:06 PM
  3. Using a Active X command button to activate a hyperlink
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-27-2009, 12:18 PM
  4. Changing a button command
    By AndySuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2008, 11:39 AM
  5. Use a command button to activate a hyperlink
    By penfold in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-27-2008, 09:33 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