LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default AllowEditRanges

I am trying to set a range to allow users to sort a range. I thought it was
working, but I get a Run-time error '1004': Application-defined or
object-defined error" when it gets to the AllowEditRanges object.

Here is the code (any suggestions to make it more efficient would also be
appreciated):
Sub ProtectAll()
Dim wks As Worksheet
Dim strPassword As String

strPassword = InputBox("Enter the password", "Password")

For Each wks In Worksheets
wks.Protection.AllowEditRanges.Add _
Title:="SortRange", _
Range:=Range("A29:S" & Range("B65000").End(xlUp).Offset(-23,
0).Row)
Next wks
For Each wks In Worksheets
wks.EnableSelection = xlNoRestrictions
wks.Protect Password:=strPassword, _
Contents:=True, _
AllowFormattingCells:=True, _
AllowSorting:=True
Next wks
End Sub
 
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
How to delete allowEditRanges programatically Sri Ram[_2_] Excel Programming 0 August 10th 06 04:53 PM
Delete Protection.AllowEditRanges mangesh_yadav[_87_] Excel Programming 2 September 6th 04 02:47 PM


All times are GMT +1. The time now is 09:57 PM.

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

About Us

"It's about Microsoft Excel"