Excel VBA - Event Problems

T

Teggaman

Hi I'm using a standard module to pull some data from various sources
and transferring them onto a sheet. The sheet also has some
selectionchange event code.

Unfortuatly, when updating my sheet, the event code kicks and checks
to see if the events been activated. The code still works, but takes
longer because of this.

Can I switch this off before running the import macro?

Thanks

Teggaman
 
L

Leo Heuser

Hi Teggaman

You disable event handling with

Application.EnableEvents = False

Be absolutely sure to set it back, when the
operation is over, with

Application.EnableEvents = True

If you don't do this Eventhandling is disabled, not
only for the workbook in question, but for the entire
Excel session.

To be on the safe side, I always do it like this:


Sub Test()

On Error Goto Finito

Application.EnableEvents = False
'code
'code
Finito:
Application.EnableEvents = True
End Sub


--
Best Regards
Leo Heuser
MVP Excel

Followup to newsgroup only please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top