Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Code looping problem

Status
Not open for further replies.

MarkBeck

Technical User
Mar 6, 2003
164
CA
Hi

This is a simple piece of code


Private Sub Worksheet_Deactivate()
Sheets("TB").Select
Range.("R1").Select
Selection.ClearContents
Sheets("BS").Select
End Sub

Why does it keep running non-stop?
 
Play with the Application.EnableEvents property :
Private Sub Worksheet_Deactivate()
Application.EnableEvents = False
' do your stuff here
Application.EnableEvents = True
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 



Hi,

Try to AVOID, Activate and Select
Code:
Private Sub Worksheet_Deactivate()
    Sheets("TB").Range.("R1").ClearContents
End Sub


Skip,

[glasses] [red][/red]
[tongue]
 
Sheets("TB").Range("R1").ClearContents

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV! That Period was the black sheep.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top