Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 100
Default macro for sorting in protected sheet

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
...Protect Password:="justme"
...EnableSelection = xlNoRestrictions
End With
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 527
Default macro for sorting in protected sheet

Hi
In Xl2003 you can set the protection in unlocked cells to allow the user to
sort - so a macro will not be needed.

Peter

"vcff" wrote:

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
..Protect Password:="justme"
..EnableSelection = xlNoRestrictions
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 100
Default macro for sorting in protected sheet

excel 2000 so no luck for that.

"Billy Liddel" wrote:

Hi
In Xl2003 you can set the protection in unlocked cells to allow the user to
sort - so a macro will not be needed.

Peter

"vcff" wrote:

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
..Protect Password:="justme"
..EnableSelection = xlNoRestrictions
End With
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default macro for sorting in protected sheet

Ok, I think I see the 'why' of your question - the code you have sorts the
entire UsedRange and not the area A6:A60 which is all you want to sort. I
presume that in your real code you're using the correct password where
needed, so...
Sub sortit()
Dim coltosort As Range
Set coltosort = ActiveSheet.Range("A6:A60")
ActiveSheet.Unprotect Password:="justme"
coltosort.Select
Selection.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
.Protect Password:="justme"
.EnableSelection = xlNoRestrictions
End With
End Sub

Note the change from .. to . for the interior of the With...End With
statements.

"vcff" wrote:

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
..Protect Password:="justme"
..EnableSelection = xlNoRestrictions
End With
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 100
Default macro for sorting in protected sheet

Hi Latham

after copying your code, it gave me a error "400"

"JLatham" wrote:

Ok, I think I see the 'why' of your question - the code you have sorts the
entire UsedRange and not the area A6:A60 which is all you want to sort. I
presume that in your real code you're using the correct password where
needed, so...
Sub sortit()
Dim coltosort As Range
Set coltosort = ActiveSheet.Range("A6:A60")
ActiveSheet.Unprotect Password:="justme"
coltosort.Select
Selection.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
.Protect Password:="justme"
.EnableSelection = xlNoRestrictions
End With
End Sub

Note the change from .. to . for the interior of the With...End With
statements.

"vcff" wrote:

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
..Protect Password:="justme"
..EnableSelection = xlNoRestrictions
End With
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 100
Default macro for sorting in protected sheet

range A4:A33 was also highlighted

"vcff" wrote:

Hi Latham

after copying your code, it gave me a error "400"

"JLatham" wrote:

Ok, I think I see the 'why' of your question - the code you have sorts the
entire UsedRange and not the area A6:A60 which is all you want to sort. I
presume that in your real code you're using the correct password where
needed, so...
Sub sortit()
Dim coltosort As Range
Set coltosort = ActiveSheet.Range("A6:A60")
ActiveSheet.Unprotect Password:="justme"
coltosort.Select
Selection.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
.Protect Password:="justme"
.EnableSelection = xlNoRestrictions
End With
End Sub

Note the change from .. to . for the interior of the With...End With
statements.

"vcff" wrote:

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
..Protect Password:="justme"
..EnableSelection = xlNoRestrictions
End With
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default macro for sorting in protected sheet

Works fine for me.

Did you copy it exactly as Rick posted?


Gord Dibben MS Excel MVP

On Sat, 20 Oct 2007 10:12:00 -0700, vcff wrote:

range A4:A33 was also highlighted

"vcff" wrote:

Hi Latham

after copying your code, it gave me a error "400"

"JLatham" wrote:

Ok, I think I see the 'why' of your question - the code you have sorts the
entire UsedRange and not the area A6:A60 which is all you want to sort. I
presume that in your real code you're using the correct password where
needed, so...
Sub sortit()
Dim coltosort As Range
Set coltosort = ActiveSheet.Range("A6:A60")
ActiveSheet.Unprotect Password:="justme"
coltosort.Select
Selection.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
.Protect Password:="justme"
.EnableSelection = xlNoRestrictions
End With
End Sub

Note the change from .. to . for the interior of the With...End With
statements.

"vcff" wrote:

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
..Protect Password:="justme"
..EnableSelection = xlNoRestrictions
End With
End Sub


  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 100
Default macro for sorting in protected sheet

Should be as I highlighted the code and paste it

"Gord Dibben" wrote:

Works fine for me.

Did you copy it exactly as Rick posted?


Gord Dibben MS Excel MVP

On Sat, 20 Oct 2007 10:12:00 -0700, vcff wrote:

range A4:A33 was also highlighted

"vcff" wrote:

Hi Latham

after copying your code, it gave me a error "400"

"JLatham" wrote:

Ok, I think I see the 'why' of your question - the code you have sorts the
entire UsedRange and not the area A6:A60 which is all you want to sort. I
presume that in your real code you're using the correct password where
needed, so...
Sub sortit()
Dim coltosort As Range
Set coltosort = ActiveSheet.Range("A6:A60")
ActiveSheet.Unprotect Password:="justme"
coltosort.Select
Selection.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
.Protect Password:="justme"
.EnableSelection = xlNoRestrictions
End With
End Sub

Note the change from .. to . for the interior of the With...End With
statements.

"vcff" wrote:

Hi all

I created a button in a protected worksheet to allow sorting of data in
column A6 to A60 which does not work. Pls help.

I used the following code which I found in the discussion group. What I need
is to sort only a range of datas in one column, eg A6 to A60

Sub sortit()
Dim coltosort As Range
Set coltosort = Application.InputBox(Prompt:= _
"Select A Column", Type:=8)
ActiveSheet.Unprotect Password:="justme"
ActiveSheet.UsedRange.Sort Key1:=coltosort.Cells(2), _
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With ActiveSheet
..Protect Password:="justme"
..EnableSelection = xlNoRestrictions
End With
End Sub



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
how to enable a macro in protected sheet Steve Eastham Excel Discussion (Misc queries) 2 May 4th 07 03:34 PM
Sorting a protected sheet Rusty Excel Worksheet Functions 1 April 19th 07 03:10 AM
Macro Error when Sheet is Protected Johnny Excel Discussion (Misc queries) 4 July 28th 06 07:43 PM
use macro button to run macro in protected sheet earl Excel Discussion (Misc queries) 3 February 26th 06 10:21 PM
How can you create a macro on a protected sheet? Felix Excel Discussion (Misc queries) 2 February 23rd 06 12:37 AM


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