Question Locked

How do you sort a password protected worksheet

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I was able to get Solution 1 in the article at the link below to work. However, how can I get this to work with a password protected worksheet?

http://articles.techrepublic.com.com/5100-10878_11-5234546.html?part=rss&tag=feed&subj=tr

The following is some code in another program that unlocks a password protected worksheet to release the filters, then it restore the pass word. Some how I need to intergrate the code in the article with the following code to unlock worksheet, sort the data by a specific column, the reapply the password.

Private Sub Workbook_Open()
Const PW As String = "123"
With Sheets("LOG") 'Change Sheet Name Here
If .FilterMode Then
.Unprotect Password:=PW
.ShowAllData
.Protect Password:=PW, DrawingObjects:=True, _
Contents:=True, Scenarios:=True, AllowFiltering:=True
End If
End With
End Sub

The worksheet has 5 columns and I want to sort by column 4 which is a date column.

1 reply

This discussion is closed to new replies.