Worksheet_Deactivate() problem with deleting data

  • Thread starter Thread starter Neil Atkinson
  • Start date Start date
N

Neil Atkinson

Hi I need to delete formaulas when a sheet deactivates but the formulas
in
the next sheet thats acivated are deleted instead, is there a way to do
this? (the formaulas are copied in when the worksheets are activated)

Private Sub Worksheet_Deactivate()
ActiveSheet.Unprotect Password:="naWages"
Range("AG17:AH41").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("AY17:CI42").Select
Selection.ClearContents
Range("A1").Select
ActiveSheet.Protect Password:="naWages"
End Sub

Regards
Neil
 
I'm not sure, but it might be because you have already deactivated the sheet.
So the activeworksheet command is focused on the new sheet. Try referencing
the sheet by name using sheets("name of sheet") instead of the activesheet
reference.
 

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