![]() |
Worksheet_Deactivate() problem with deleting data
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 *** Sent via Developersdex http://www.developersdex.com *** |
Worksheet_Deactivate() problem with deleting data
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. "Neil Atkinson" wrote: 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 *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 07:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com