vb command to snap to default button

Reset

Board Regular
Joined
Apr 16, 2010
Messages
227
Is there a command to have the pointer snap to the default selection in a msgbox?
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

AgentSmith

Well-known Member
Joined
Mar 8, 2004
Messages
575
There is a Windows setting for that so perhaps there might be an API call you can use. To find it in Windows yourself have a look at the mouse settings in Control Panel. There should be a tick box labelled "Automatically move pointer to the default button in a dialog box" or something similar.

On a related note, you can control which button is the default on a MsgBox. E.g. instead of just "vbYesNo" try "vbYesNo + vbDefaultButton2" to make No the default option. This allows you to change what happens when the user presses the ENTER key, which might be a good half-way house?
 

AgentSmith

Well-known Member
Joined
Mar 8, 2004
Messages
575
PS - personally I'd avoid doing exactly what you propose. Some people like the mouse to do that, others don't. Those that do like it can tick the box in Control Panel (or you can show them how) so why interfere? You might just confuse the people you are trying to help!
 
Last edited:

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,052
Messages
5,509,046
Members
408,701
Latest member
daz457

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top