ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open a UserForm when a Tab is selected (https://www.excelbanter.com/excel-programming/412625-open-userform-when-tab-selected.html)

SJW_OST[_2_]

Open a UserForm when a Tab is selected
 
I would be most appreciative if someone can help me with this.
I have a user form that I want to show when a TAB, Sheet1, is selected then
hide again when ANY other TAB, Sheet2, Sheet3, etc..., is selected. I've seen
similar posting to do this when a cell is selected but I could not get them
to work when a TAB is selected.
Thank you in advance.

Harald Staff[_2_]

Open a UserForm when a Tab is selected
 
Put the commands in the sheet's Worksheet_activate / Worksheet_deactivate
events, ot in the workbook's SheetActivate / SheetDeactivate events.

HTH. Best wishes Harald


"SJW_OST" wrote in message
...
I would be most appreciative if someone can help me with this.
I have a user form that I want to show when a TAB, Sheet1, is selected
then
hide again when ANY other TAB, Sheet2, Sheet3, etc..., is selected. I've
seen
similar posting to do this when a cell is selected but I could not get
them
to work when a TAB is selected.
Thank you in advance.



SJW_OST[_2_]

Open a UserForm when a Tab is selected
 
That works great!
The only problem I have now is I have macros that constantly activate the
TAB I want that userform to auto-populate on when activated/clicked on. I
tried putting "UserForm.Hide" command just behind each call of the sheet in
the various macros but it did not make the userform stay hidden for the
duration of the other macro(s) run, so the userform is intrupting the run of
the other macros. Unless you have something that is code based, I think I'll
just tie the userform to a button on the sheet. Any thoughts?
Otherwise what you gave worked as I initially wanted. Thanks again.

"Harald Staff" wrote:

Put the commands in the sheet's Worksheet_activate / Worksheet_deactivate
events, ot in the workbook's SheetActivate / SheetDeactivate events.

HTH. Best wishes Harald


"SJW_OST" wrote in message
...
I would be most appreciative if someone can help me with this.
I have a user form that I want to show when a TAB, Sheet1, is selected
then
hide again when ANY other TAB, Sheet2, Sheet3, etc..., is selected. I've
seen
similar posting to do this when a cell is selected but I could not get
them
to work when a TAB is selected.
Thank you in advance.




Harald Staff[_2_]

Open a UserForm when a Tab is selected
 
Hi

Is it so that your code selects a sheet to do something there ? Selection by
code is almost never necessary, you can work there by addressing it
directly, like
Sheets("Sheet12").Range("A1:C14").Clear

Best wishes Harald

"SJW_OST" wrote in message
...
That works great!
The only problem I have now is I have macros that constantly activate the
TAB I want that userform to auto-populate on when activated/clicked on. I
tried putting "UserForm.Hide" command just behind each call of the sheet
in
the various macros but it did not make the userform stay hidden for the
duration of the other macro(s) run, so the userform is intrupting the run
of
the other macros. Unless you have something that is code based, I think
I'll
just tie the userform to a button on the sheet. Any thoughts?
Otherwise what you gave worked as I initially wanted. Thanks again.



All times are GMT +1. The time now is 02:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com