Hi, This is Krish and I'm New to Macros. The Problem I'm facing is " I have a workbook with multiple sheets. I'm Using a Macro which copies the data from the active sheet and exports it to other sheet (Not into the existing workbook) and save it with a specific file name based on cell values. In Each sheet some cells has some formula which shouldn't be edited. So, when i try to protect those cells the Macro is not running. I tried the (ActiveSheet.Unprotect password:="yourpassword" code along with protect) but its not working since the active sheet changes after running the macro. Can some one help ? ?
Here's the code I'm using to move/copy the data
Sub Report_Transfer()
ActiveSheet.Unprotect password:="yourpassword" ----> Tried this line but its Notworking (The sheet gets unlocked but doesn't get locked again)
ActiveSheet.Copy
With ActiveSheet.UsedRange
.Copy
.PasteSpecial xlValues
.PasteSpecial xlFormats
End With
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:=Range("B2") & "_" & Range("D3") & ".xls"
ActiveSheet.Protect password:="yourpassword"
End Sub
Thanks in Advance...
Bookmarks