Possible to bypass event if called by specific macro?


Posted by Catherine Munro on November 15, 2001 12:27 PM

I have a simple event on Worksheet 1 that I like the way it is.

'Resize display
Private Sub Worksheet_Activate()
Worksheets(1).Range("C6:Q6").Select
ActiveWindow.Zoom = True
Worksheets(1).Range("C6").Select
End Sub

However, it's glitching up another procedure that needs to paste data to to that Worksheet. I think it's because the Select is interfering with having data on the clipboard.

Problem line in macro 2:
Worksheets(1).Paste Destination:=Worksheets(1).Range("LVL02_CausalData")

Any ideas how to handle? Should I handle transferring data differently? Or is there a way to identify that the Worksheet is being activated by this particular macro, so I can put an IF in the event procedure?

Thanks!
Catherine

Posted by Mark O'Brien on November 15, 2001 1:05 PM

OK, is your second Macro on a worksheet object just like the code above or is it in a module?

I'm assuming that the other macro is in a module. There's a way to make an "If" statement.

In the module of the other macro, put this line of code at the very top of the module in the declarations section:

Public booChck As Boolean

Then use this code around the paste statement:

booChck = True
Worksheets(1).Paste Destination:=Worksheets(1).Range("LVL02_CausalData")
booChck = False

then put this code on your sheet in place of your zoom code:

'Resize display
Private Sub Worksheet_Activate()
If Not booChck = True then
Worksheets(1).Range("C6:Q6").Select
ActiveWindow.Zoom = True
Worksheets(1).Range("C6").Select
End If
End Sub

Any problems or questions, just repost.



Posted by Catherine Munro on November 15, 2001 1:26 PM

Oh that works beautifully, thank you!!

Sorry, next time I'll specify that... :)

Major thank yous -- you just saved my deadline!
Cath