PC Review


Reply
Thread Tools Rate Thread

AllowEditRanges

 
 
Josh O.
Guest
Posts: n/a
 
      3rd Jan 2008
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
 
Reply With Quote
 
 
 
 
Mark Ivey
Guest
Posts: n/a
 
      4th Jan 2008
Josh,

It appears that your Range call has some type of circular reference. If you
can provide some instructions on what you are trying to attempt, maybe
someone could help out a bit more (i.e. - what is the specified range you
are wanting to work with, etc.)


Mark Ivey


"Josh O." <(E-Mail Removed)> wrote in message
news:85425FA2-297F-43D8-B960-(E-Mail Removed)...
> 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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method 'Range' fails while using AllowEditRanges Arkansas Lady Microsoft Excel Programming 0 24th Sep 2008 04:26 PM
How to delete allowEditRanges programatically =?Utf-8?B?U3JpIFJhbQ==?= Microsoft Excel Programming 0 10th Aug 2006 04:53 PM
Delete Protection.AllowEditRanges mangesh_yadav Microsoft Excel Programming 2 6th Sep 2004 02:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:14 AM.