ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting Rows on a password protected worksheet (https://www.excelbanter.com/excel-programming/377010-sorting-rows-password-protected-worksheet.html)

CoachTony

Sorting Rows on a password protected worksheet
 
Hello,
I have an MS Excel worksheet (Excel 2002), for which I have password
protectection enabled.

There are several columns which the users can enter data, they would also
like to sort the data (both asc. & desc.), but as you know, sorting functions
are disabled when protection is on.

I have tried this code, to no avail:
----------------------------------------------------------------------------------------------
Sub SortSheet()

ActiveSheet.Unprotect Password:="cfo2006"
Range("A14:Q14").Sort Key1:=Range("C14"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect Password:="cfo2006", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End Sub
---------------------------------------------------------------------------------------------
Can you offer any ideas to help me with this problem??
--
Thanks in advance for your assistance!
Coach Tony

Sandy

Sorting Rows on a password protected worksheet
 
It looks like your range is only one row and you are sorting top to
bottom so when it sorts there is only one variable in the column to
sort, try setting the range to cover all the data and then run the
code.

Sandy

CoachTony wrote:
Hello,
I have an MS Excel worksheet (Excel 2002), for which I have password
protectection enabled.

There are several columns which the users can enter data, they would also
like to sort the data (both asc. & desc.), but as you know, sorting functions
are disabled when protection is on.

I have tried this code, to no avail:
----------------------------------------------------------------------------------------------
Sub SortSheet()

ActiveSheet.Unprotect Password:="cfo2006"
Range("A14:Q14").Sort Key1:=Range("C14"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect Password:="cfo2006", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End Sub
---------------------------------------------------------------------------------------------
Can you offer any ideas to help me with this problem??
--
Thanks in advance for your assistance!
Coach Tony



Sandy

Sorting Rows on a password protected worksheet
 
If you are trying to sort by row change the orientation to
xlLeftToRight. If you are sorting by columns then you need to adjust
your range , you only have one row of data in each column to sort.

Sandy

CoachTony wrote:
Hello,
I have an MS Excel worksheet (Excel 2002), for which I have password
protectection enabled.

There are several columns which the users can enter data, they would also
like to sort the data (both asc. & desc.), but as you know, sorting functions
are disabled when protection is on.

I have tried this code, to no avail:
----------------------------------------------------------------------------------------------
Sub SortSheet()

ActiveSheet.Unprotect Password:="cfo2006"
Range("A14:Q14").Sort Key1:=Range("C14"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect Password:="cfo2006", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End Sub
---------------------------------------------------------------------------------------------
Can you offer any ideas to help me with this problem??
--
Thanks in advance for your assistance!
Coach Tony



CoachTony

Sorting Rows on a password protected worksheet
 
Sandy, YOU ARE AWESOME!

Works like a charm, when you set it up correctly -)

Thanks very much for your quick response, I appreciate it!
--
Coach Tony


"Sandy" wrote:

If you are trying to sort by row change the orientation to
xlLeftToRight. If you are sorting by columns then you need to adjust
your range , you only have one row of data in each column to sort.

Sandy

CoachTony wrote:
Hello,
I have an MS Excel worksheet (Excel 2002), for which I have password
protectection enabled.

There are several columns which the users can enter data, they would also
like to sort the data (both asc. & desc.), but as you know, sorting functions
are disabled when protection is on.

I have tried this code, to no avail:
----------------------------------------------------------------------------------------------
Sub SortSheet()

ActiveSheet.Unprotect Password:="cfo2006"
Range("A14:Q14").Sort Key1:=Range("C14"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect Password:="cfo2006", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End Sub
---------------------------------------------------------------------------------------------
Can you offer any ideas to help me with this problem??
--
Thanks in advance for your assistance!
Coach Tony





All times are GMT +1. The time now is 02:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com