Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default button focus

Hello, Need to know how to tell if a button has the focus.
thanks
bill


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default button focus

I don't know a way to do it in Excel VBA. But if you want a control to get the focus, you can use "SetFocus".

But even if there is a way to do it, I don't know how it can be applied. Maybe you can share with us why you need to do that.

----- billq wrote: -----

Hello, Need to know how to tell if a button has the focus.
thanks
bill



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default button focus

Set a flag in code when the button is clicked, reset the flag when
something else (another control, a worksheet cell, etc as appropriate)
is selected. Then, to know if the button has the focus, test the flag.

"billq" wrote in message ...
Hello, Need to know how to tell if a button has the focus.
thanks
bill

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default button focus

Hi and thanks for the reply. I have a combination of cells, command
buttons, and radio buttons that I am trying to set up a tab order using
Application.OnKey("{TAB}", "tabPress" to capture the tab key. For tabPress
I am using if then, elseif
structure to determine the active cell or button and where to move the
focus.
ex) if ActiveCell = Range("AccountNumber") then
Application.Goto Reference "Amount"
else if ActiveCell = Range("Amount") then
Sheet1.CashRB.Activate
else if Sheet1.CashRB 'this is where I need to determine if the
control has the focus so that I can move the focus to the next control

how this give you more idea as to what I am trying to do. If I had to do it
all over again I would make this sheet a form by itself.
thanks
bill

"billq" wrote in message
...
Hello, Need to know how to tell if a button has the focus.
thanks
bill




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default button focus

Something like:

Private m_blnHasFocusCashRB

If m_blnHasFocusCashRB Then

Application.Goto Reference "AccountNumber"
m_blnHasFocusCashRB = False

Else

If ActiveCell = Range("AccountNumber") then
Application.Goto Reference "Amount"
else if ActiveCell = Range("Amount") then
Sheet1.CashRB.Activate
m_blnHasFocusCashRB = True
End if

End if


"billQ" wrote in message ...
Hi and thanks for the reply. I have a combination of cells, command
buttons, and radio buttons that I am trying to set up a tab order using
Application.OnKey("{TAB}", "tabPress" to capture the tab key. For tabPress
I am using if then, elseif
structure to determine the active cell or button and where to move the
focus.
ex) if ActiveCell = Range("AccountNumber") then
Application.Goto Reference "Amount"
else if ActiveCell = Range("Amount") then
Sheet1.CashRB.Activate
else if Sheet1.CashRB 'this is where I need to determine if the
control has the focus so that I can move the focus to the next control

how this give you more idea as to what I am trying to do. If I had to do it
all over again I would make this sheet a form by itself.
thanks
bill

"billq" wrote in message
...
Hello, Need to know how to tell if a button has the focus.
thanks
bill


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the focus Orf Bartrop New Users to Excel 4 August 9th 06 05:36 AM
focus Capp Excel Discussion (Misc queries) 2 November 18th 05 07:25 PM
set focus tkaplan Excel Discussion (Misc queries) 3 September 27th 05 07:41 PM
Focus David Unger Excel Worksheet Functions 20 March 21st 05 06:43 PM
set focus RickK Excel Programming 1 October 10th 03 12:27 PM


All times are GMT +1. The time now is 08:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"