![]() |
Can I disable Worksheet_activate???
Any Excel guru can help me??
I have three sheets (Sheet1, Sheet2, Sheet3). Sheet2 has Worksheet_activate(Macro) on it. Let say, I'm working on sheet1,if I move to Sheet2, then, Worksheet_activate in sheet2 will be activates, right? My question is, how can I (if possible) to disable the Worksheet_activate to run in sheet2 if I move from sheet3 to sheet2 ?? I just want the Worksheet_activate in sheet2 running, only if I move from sheet1. Thank you. |
Can I disable Worksheet_activate???
I am not sure whether this is correct move sanctioned by mvps
in the intermediate window of vba I type application.enableevents=false and hit enter then after my work isover i again type in the intermesdiate window application.enableevents=true and then hit enter. so that the worksheets activate macro of sheet2 can now work. try this and see ======================================= broogle wrote in message oups.com... Any Excel guru can help me?? I have three sheets (Sheet1, Sheet2, Sheet3). Sheet2 has Worksheet_activate(Macro) on it. Let say, I'm working on sheet1,if I move to Sheet2, then, Worksheet_activate in sheet2 will be activates, right? My question is, how can I (if possible) to disable the Worksheet_activate to run in sheet2 if I move from sheet3 to sheet2 ?? I just want the Worksheet_activate in sheet2 running, only if I move from sheet1. Thank you. |
Can I disable Worksheet_activate???
You can use the *Private Sub Worksheet_Deactivate()* in all sheets to set the a global var. Then you can check in *Private Sub Worksheet_Activate()* of sheet2 where you are comming from. And you can deside to run code if you're from sheet1. Jeroen -- Kaak ------------------------------------------------------------------------ Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513 View this thread: http://www.excelforum.com/showthread...hreadid=383017 |
Can I disable Worksheet_activate???
This is the sort of code Jeroen was referring to. Not that I use the
worksheet codename not name, in case a user gets cute and changes the name Public LastSheet As String Private Sub Workbook_SheetActivate(ByVal Sh As Object) If Sh.CodeName = "Sheet2" Then If LastSheet = "Sheet3" Then 'ok, so let go Else Worksheets(ThisWorkbook.VBProject.VBComponents(Las tSheet) _ .Properties("Name").Value).Activate End If End If End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) LastSheet = Sh.CodeName End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH Bob Phillips "Kaak" wrote in message ... You can use the *Private Sub Worksheet_Deactivate()* in all sheets to set the a global var. Then you can check in *Private Sub Worksheet_Activate()* of sheet2 where you are comming from. And you can deside to run code if you're from sheet1. Jeroen -- Kaak ------------------------------------------------------------------------ Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513 View this thread: http://www.excelforum.com/showthread...hreadid=383017 |
All times are GMT +1. The time now is 12:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com