Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protecting worksheet within an Macro


Hello. Boy, do I need help....

I had to unprotect and protect a worksheet within a macro to get some
code to run. Problem: The protection variables that I originally
assigned when I manually protected the sheet (and before the macro was
run for the first time), such as allow the user to format unlocked
cells, columns, and rows is modified. Is there a way to keep these
protection variables in tact with the macro code?? I'm running excel
2003, but some users will be running 2000.

Worksheets("DOLLARS").Unprotect Password:="HAPPY"
Range("U9:AF9").Select
Selection.EntireColumn.Hidden = True
Range("AG10:AN10").Select
Selection.EntireColumn.Hidden = False
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Range("B13").Select
Worksheets("DOLLARS").Protect Password:="HAPPY"
End Sub

I appreciate any input.


--
Thor
------------------------------------------------------------------------
Thor's Profile: http://www.excelforum.com/member.php...fo&userid=1049
View this thread: http://www.excelforum.com/showthread...hreadid=499160

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Protecting worksheet within an Macro

Hi Thor

Try something like

Worksheets("DOLLARS").Unprotect Password:="HAPPY"
Range("U9:AF9").EntireColumn.Hidden = True
Range("AG10:AN10").EntireColumn.Hidden = False
Range("B13").Select
ActiveSheet.Protect Password="HAPPY", DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowSorting:=True,
AllowFiltering:=True, _
AllowUsingPivotTables:=True



--
Regards

Roger Govier


"Thor" wrote in
message ...

Hello. Boy, do I need help....

I had to unprotect and protect a worksheet within a macro to get some
code to run. Problem: The protection variables that I originally
assigned when I manually protected the sheet (and before the macro was
run for the first time), such as allow the user to format unlocked
cells, columns, and rows is modified. Is there a way to keep these
protection variables in tact with the macro code?? I'm running excel
2003, but some users will be running 2000.

Worksheets("DOLLARS").Unprotect Password:="HAPPY"
Range("U9:AF9").Select
Selection.EntireColumn.Hidden = True
Range("AG10:AN10").Select
Selection.EntireColumn.Hidden = False
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Range("B13").Select
Worksheets("DOLLARS").Protect Password:="HAPPY"
End Sub

I appreciate any input.


--
Thor
------------------------------------------------------------------------
Thor's Profile:
http://www.excelforum.com/member.php...fo&userid=1049
View this thread:
http://www.excelforum.com/showthread...hreadid=499160



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protecting worksheet within an Macro


Roger:
Thx for the tip. This is good as you wrote for 2003, however it doesn't
work in 2000 and a runtime 1004 error is created. I removed the
"allow---" formatting code only, because that appears to be applicable
to 2003 only, and ran it again in 2000 with the same 1004 error. This
might be a case that there is no way to run this across both
versions...

Thank you.
Thor.


--
Thor
------------------------------------------------------------------------
Thor's Profile: http://www.excelforum.com/member.php...fo&userid=1049
View this thread: http://www.excelforum.com/showthread...hreadid=499160

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protecting worksheet Patricia Excel Discussion (Misc queries) 1 March 15th 10 02:49 PM
Protecting worksheet Kimti Excel Worksheet Functions 1 July 6th 08 01:37 AM
hiding macro codes upon protecting the worksheet eehj23 Excel Discussion (Misc queries) 1 April 28th 06 03:55 AM
Macro problem with protecting worksheet........... PKyle Excel Programming 9 August 2nd 04 04:24 PM
Protecting worksheet Shilps Excel Programming 2 April 27th 04 01:01 PM


All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"