Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Visual basic unlock "SORT" function in an EXCEL spreadsheet

How do I add a string to enable the "SORT" function in the following
workbook?

My current string in the spreadsheet is as follows:

Private Sub Workbook_Open()

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets(Array("Key Controls", "NonKey
Controls"))
With ws
.Protect Password:="sox2005", DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
userinterfaceonly:=True
.EnableAutoFilter = True
.EnableOutlining = True
End With
Next ws
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Visual basic unlock "SORT" function in an EXCEL spreadsheet

In Excel 2002 and later, it is an argument to the Protect methods.

In earlier versions, you can't enable it. However, you should be still be
able to sort with code using the UserInterfaceOnly argument.

--
Regards,
Tom Ogilvy

"Jetty" wrote in message
oups.com...
How do I add a string to enable the "SORT" function in the following
workbook?

My current string in the spreadsheet is as follows:

Private Sub Workbook_Open()

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets(Array("Key Controls", "NonKey
Controls"))
With ws
.Protect Password:="sox2005", DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
userinterfaceonly:=True
.EnableAutoFilter = True
.EnableOutlining = True
End With
Next ws
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Visual basic unlock "SORT" function in an EXCEL spreadsheet

Thanks for your reply. I have Excel 2003 and
1) I did try to unprotect the file first
2) Placed a check mark in the sort box
3) Saved the file with the password
4) Closed the file
5) Re-Opened the file, enabling the macros
6) The sort function is still disabled

Any ideas?


Jetty

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Visual basic unlock "SORT" function in an EXCEL spreadsheet

Here are the arguments to Protect:

expression.Protect(Password, DrawingObjects, Contents, Scenarios,
UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns,
AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows,
AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows,
AllowSorting, AllowFiltering, AllowUsingPivotTables)

You are not setting the AllowSorting argument in your code.

Here is what help says about that argument:

AllowSorting Optional Variant. True allows the user to sort on the
protected worksheet. Every cell in the sort range must be unlocked or
unprotected. The default value is False.


--
Regards,
Tom Ogilvy


"Jetty" wrote in message
...
Thanks for your reply. I have Excel 2003 and
1) I did try to unprotect the file first
2) Placed a check mark in the sort box
3) Saved the file with the password
4) Closed the file
5) Re-Opened the file, enabling the macros
6) The sort function is still disabled

Any ideas?


Jetty

*** Sent via Developersdex http://www.developersdex.com ***



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Visual basic unlock "SORT" function in an EXCEL spreadsheet

Thanks Tom for your help! It works!
Jetty

*** Sent via Developersdex http://www.developersdex.com ***


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
Excel crashes on "Close" Visual Basic error 400 [email protected] Excel Discussion (Misc queries) 3 March 19th 08 03:45 PM
"Microsoft Visual Basic runtime error '424' object required". SharonG. Excel Worksheet Functions 0 July 5th 06 01:36 AM
visual basic example of the defunct "Extract" function in Excel 4. Canuckle Head Excel Programming 1 December 29th 04 04:38 AM
Registry key for "Trust access to Visual Basic project" tmarko[_13_] Excel Programming 3 June 14th 04 10:40 AM
How to set equivalent of Visual Basic "redraw = false" GrantS Excel Programming 4 January 15th 04 06:13 PM


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