Need help checking focus on userform

obener

Board Regular
Joined
May 31, 2009
Messages
118
Hi all,

i got showmodal=false on a userform and wanted to know if there was a way to check if the focus was on the sheet or on the userform?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
i know userform.setfocus will set focus to it but is there a way to check if focus is on the userform?
 
Upvote 0
A userform does not have a setfocus method. Why do you need to know if the focus is there?
 
Upvote 0
A userform does not have a setfocus method. Why do you need to know if the focus is there?


what i want to be able to do is let the user to move down/up/left/right on the page without having to be touch the sheet at all or setting showmodal to false. As the userform is used to enter data into the sheet. The two other ways i thought of doing this was:

1) protect the sheets with a password and set showmodal to false and every time new information is entered using the userform, use vba to unlock and lock it.
2) when the userform is closed protect the sheets with a password and when the userform is active take password off
3) the way i wanted to do is being able to move on the sheet without having to lock and unlock it! i thought checking focus on userform i could unlock, and lock when focus isnt on userfom.
 
Upvote 0
I don't really understand. If you don't show the form modelessly, the user can't touch the sheet at all.
You may be able to simply protect the sheet using the userinterfaceonly:=true argument which will allow your code to do (almost) anything it needs to without allowing the users to change anything themselves.
 
Upvote 0
Perhaps show it modally and assign a routine to change the scroll properties of the spreadsheet on the arrow key events?
 
Upvote 0
I don't really understand. If you don't show the form modelessly, the user can't touch the sheet at all.
You may be able to simply protect the sheet using the userinterfaceonly:=true argument which will allow your code to do (almost) anything it needs to without allowing the users to change anything themselves.

yeah i will have to allow vbmodeless. is there another argument like userinterfaceonly:=true that i can use not allow to select locked cells as i dont want users to modify the cell contents, i want the userform to do that. as there is a barcode reader attached which acts as a keyboard, when clicked back on the userform i want it to focus on a textbox, is this possible?
 
Upvote 0
If you protect with userinterfaceonly:=true the user cannot change anything unless you unlock it. In the protection settings you can specify whether they can select locked cells.
 
Upvote 0

Forum statistics

Threads
1,214,518
Messages
6,119,985
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top