ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   VBA password protect (https://www.excelbanter.com/new-users-excel/99535-vba-password-protect.html)

brian thompson3001 via OfficeKB.com

VBA password protect
 
Hi

I have got this macro to run when opening. All works, but when I password
protect the sheet, and then close and open i get a run error.

I am not fluent with VBA and get by by recording and pasting other work off
the treads

Can anyone let me have the VBA code for protect / unprotect. and where it
should be entered in the code below . The password is "template"

thanks in advance

Private Sub auto_Open()
Sub averagesort()
Range("A6:AI36").Select
Selection.Sort Key1:=Range("C6"), Order1:=xlDescending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlBottomToTop
ActiveWindow.ScrollRow = 6
Range("A3").Select
End Sub


Signature


bnt

--
bnt

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...l-new/200607/1

Dave Peterson

VBA password protect
 
You have a reply at your other post.

"brian thompson3001 via OfficeKB.com" wrote:

Hi

I have got this macro to run when opening. All works, but when I password
protect the sheet, and then close and open i get a run error.

I am not fluent with VBA and get by by recording and pasting other work off
the treads

Can anyone let me have the VBA code for protect / unprotect. and where it
should be entered in the code below . The password is "template"

thanks in advance

Private Sub auto_Open()
Sub averagesort()
Range("A6:AI36").Select
Selection.Sort Key1:=Range("C6"), Order1:=xlDescending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlBottomToTop
ActiveWindow.ScrollRow = 6
Range("A3").Select
End Sub

Signature

bnt

--
bnt

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...l-new/200607/1


--

Dave Peterson


All times are GMT +1. The time now is 03:06 PM.

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