Read on full site | Join TechSpot! (it's free) | Bookmark / Share this



Re-Protecting Excel Sheet via Macro

timmy1982
01-22-2008, 08:30 AM
Hello,

I have built a small, simple Macro in Excel which simply un-protects a sheet, copies and pastes some data from another sheet, and then re-protects the sheet. However, when I run the Macro, a prompt asking for a password to un-protect the sheet is asked, which is fine, then the copy and paste happens, however, I am not asked to enter a password to re-protect the sheet.

When I exit the Macro, the sheet appears to be protected, however, simply selecting the un-protect sheet option, will un-protect it without prompting for a password. Is there something I'm missing? I wish to re-protect the sheet, where a password is required.

Code:

Sub Macro2()

Sheets("Old").Select
ActiveSheet.Unprotect
Sheets("Totals").Select
Range("A9:S400").Select
Selection.Copy
Sheets("Old").Select
Range("A9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub

Any help would be gratefully received, thanks.

Post a reply, see related topics & more

Tip: Download Advanced SystemCare 3 Free - Clean, Repair, Protect & Optimize your PC.



 Top Technology News

TechSpot Blog: Disable Windows automatic check for solutions after a program crashes

Weekend Open Forum: Google Chrome OS and the future of cloud computing

Tech Tip of the Week: Unearth Region-Specific Windows 7 Themes

Gartner: PC shipments to grow 2.8% in 2009, revenue down 11%

Microsoft issues warning for IE6, IE7 security hole

LG X120 netbook to launch in the US for $180 with two-year AT&T contract

Intel's six-core Gulftown processor benchmarked months early

Another iPhone worm spotted, this time it's dangerous

More Tech News

  
 Software Downloads

FlashGot 1.2.0.9

RemoveIT Pro XT - SE 23.11.2009

Vuze (Formerly Azureus) 4.3.0.4

RemoveIT Pro v7 Enterprise 23.11.2009

Aloaha PDF Suite 3.9.172

Blindwrite Suite 6.3.1.5

RemoveIT Pro v7 Ultra 23.11.2009

More Downloads



Copyright © 1998-2009 TechSpot.com. TechSpot is a registered trademark. All Rights Reserved.