Excel VB

F

Fred

I have the following procedure at the worksheet level in
an Excel workbook. It essentially keeps the worksheet
protected upon a selection change. I need to deactivate
this procedure when a macro is run from a button and then
reactivate it when the button macro has been completed.
Any thoughts?



Private Sub Worksheet_SelectionChange(ByVal Target As
Range)

ActiveSheet.Protect DrawingObjects:=True,
Contents:=True, _
Scenarios:=True, AllowDeletingRows:=True
End Sub
 
C

Chip Pearson

Fred,

You can use the EnableEvents property to temporarily prevent
events from being triggered. E.g.,

Application.EnableEvents = False
'
' your code here
'
Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
H

Harald Staff

Hi

Put
ActiveSheet.Unprotect
in your button macro.

HTH. Best wishes Harald
 
Top