Ensure workbook is always the active workbook

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
On my useform I have several objects like listbox, multipages and buttons, is it possible to ensure that if ANY object is clicked on a userform or the userform itself is clicked then the correct WORKBOOK that contains the useform will become the ACTIVE workbook.

Users are getting error messages, mainly due to the correct workbook not being the active workbook. This happens when the user has several workbooks open and the correct workbook with the userform IS NOT the active workbook the code crashes as script out of range.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Safest option is to preface all sheets and ranges with the workbook name & sheet name. That way you are guaranteed to be looking at the correct sheet.
 
Upvote 0
Thanks, Fluff. I did think of that but its a big job I was hoping for a quick fix. one click to do it all
 
Upvote 0
On my useform I have several objects like listbox, multipages and buttons, is it possible to ensure that if ANY object is clicked on a userform or the userform itself is clicked then the correct WORKBOOK that contains the useform will become the ACTIVE workbook.

Users are getting error messages, mainly due to the correct workbook not being the active workbook. This happens when the user has several workbooks open and the correct workbook with the userform IS NOT the active workbook the code crashes as script out of range.
I had a similar problem, and found out, that it was related to the Multipage selections, itself. If a selected Multipage was selected, and the Sheet belonging to that, was NOT the active, I got an error (as you). So my solution was, that for each Multipage, I did Set the Sheet for that actual Page, on the Form. That solwed the problem for me.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

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