How to set back focus on a command button after it looses it due to some event
Hi All,
I have 4 command buttons commandbutton1 - 4 on my excel 'Sheet8'.
I want Bold-Font for whichever of the buttons 1 - 3 get focus.
Button 4 is just a settings button that doesn't need focus, it basically Opens up a UserForm when clicked.
I defined LostFocus() for buttons 1-3 and they work fine. They basically sort my columns for some names.
Now, when i click button 1, it gets focus, Bolds out its font, sorts out my columns on name "GGG". BUttons 2,3 work the same. But when i click button 4:
1) Last Button from 1-3 looses focus, UnBolds its font.(Expected)
2) UserForm opens, i click OK button to close it.
3) Now, none of my Buttons from 1-3 are selected, but my sheet is still shorted on one of my last active Buttons from 1-3.
I want one of the 3 buttons to either maintain its bold text, or regain focus back on closing UserForm, dunno how to identify the last active CommandButton before clicking Commandbutton4. How do i do that?
thanks
Mamu
Re: How to set back focus on a command button after it looses it due to some event
I assume you are doing this from within Excel so I've moved your thread here.
Re: How to set back focus on a command button after it looses it due to some event
declare a variable in the general section at the top of the codepane for sheet8
when buttons 1 to 3 are clicked set the variable
when the userform is closing setfocus to the command button based on the variable
Re: How to set back focus on a command button after it looses it due to some event
I got that fixed, now the problem is, when i click anywhere on the sheet, my command buttons loose focus. Or when i click other buttons on the sheet (other than above 4 command buttons), same thing happens. How do i get to hold focus on those 3 command buttons in this situation?
Thank for replying Pete?
Re: How to set back focus on a command button after it looses it due to some event
perhaps you should look at replacing the command buttons with togglebuttons they probably do what you want by default
Re: How to set back focus on a command button after it looses it due to some event
Thanks westconn1, i really like this idea, this would make my life lot easier.