Excel VB

  • Thread starter Thread starter Fred
  • Start date Start date
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
 
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
 
Hi

Put
ActiveSheet.Unprotect
in your button macro.

HTH. Best wishes Harald
 

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

Back
Top