Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 33
Default automatic column sorting problem when protecting sheet

I used the following formula to autosort data in a column with good results:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

The problem is that when I protect the sheet, I get the following error:

runtime error '1004':
Sort message of Range class failed

whereupon it gives me the option to debug. The cells in this particular
column are not protected.

How do I fix this? Thanks in advance for your help.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 52
Default automatic column sorting problem when protecting sheet

Two solutions, one of which should work:

1) When you protect the sheet, there is a list of things you can allow
the user to do, with checkboxes. Try ticking the "Sort" check box. This
might work in itself.

2) If the above does not work, then add the following lines to your code:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Unprotect (password)

Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1,MatchCase:=False,
Orientation:=xlTopToBottom

Activesheet.Protect (password)

End Sub


"Montana" wrote:

I used the following formula to autosort data in a column with good results:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

The problem is that when I protect the sheet, I get the following error:

runtime error '1004':
Sort message of Range class failed

whereupon it gives me the option to debug. The cells in this particular
column are not protected.

How do I fix this? Thanks in advance for your help.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 33
Default automatic column sorting problem when protecting sheet

The first solution worked like a charm. Thanks again.

"Dom_Ciccone" wrote:

Two solutions, one of which should work:

1) When you protect the sheet, there is a list of things you can allow
the user to do, with checkboxes. Try ticking the "Sort" check box. This
might work in itself.

2) If the above does not work, then add the following lines to your code:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Unprotect (password)

Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1,MatchCase:=False,
Orientation:=xlTopToBottom

Activesheet.Protect (password)

End Sub


"Montana" wrote:

I used the following formula to autosort data in a column with good results:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

The problem is that when I protect the sheet, I get the following error:

runtime error '1004':
Sort message of Range class failed

whereupon it gives me the option to debug. The cells in this particular
column are not protected.

How do I fix this? Thanks in advance for your help.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 52
Default automatic column sorting problem when protecting sheet

You're welcome and thank you for letting me know.

"Montana" wrote:

The first solution worked like a charm. Thanks again.

"Dom_Ciccone" wrote:

Two solutions, one of which should work:

1) When you protect the sheet, there is a list of things you can allow
the user to do, with checkboxes. Try ticking the "Sort" check box. This
might work in itself.

2) If the above does not work, then add the following lines to your code:

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Unprotect (password)

Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1,MatchCase:=False,
Orientation:=xlTopToBottom

Activesheet.Protect (password)

End Sub


"Montana" wrote:

I used the following formula to autosort data in a column with good results:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

The problem is that when I protect the sheet, I get the following error:

runtime error '1004':
Sort message of Range class failed

whereupon it gives me the option to debug. The cells in this particular
column are not protected.

How do I fix this? Thanks in advance for your help.

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 a sheet yet allowing for sorting, filtering, formatting [email protected] Excel Discussion (Misc queries) 0 June 28th 06 03:39 PM
Protecting Sheet and still allowing for sorting, filtering and formatting [email protected] Excel Discussion (Misc queries) 0 June 26th 06 05:19 PM
Problem created by sorting linked sheet Becks Excel Discussion (Misc queries) 2 May 2nd 06 12:28 PM
How do I lock the Column without Protecting the Sheet sgmoorthy Excel Discussion (Misc queries) 2 November 4th 05 02:00 PM
Realtime Automatic sorting of data in rows in new work sheet Gazzali Excel Worksheet Functions 0 June 23rd 05 09:35 AM


All times are GMT +1. The time now is 06:39 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"