Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default protect unprotect sheet vba

I'm hoping someone could help with this
'Sub sort()
''
'' sort Macro
'' Macro recorded 6/11/2007 by Ibartlett
'Const csPWORD As String = "CRU"
'ActiveWorkbook.Worksheets("Sorted_BedBoard_List") .Unprotect
Password:=csPWORD
'
'
' Sheets("Sorted_BedBoard_List").Select
' Columns("A:G").Select
' Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
' DataOption1:=xlSortNormal
' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
' Sheets("Sheet1").Select
' Range("D5").Select
' ActiveWorkbook.Worksheets("Sorted_BedBoard_List"). Protect
Password:=csPWORD
'
'End Sub

this doesn't work

this works but doesn't incorporate the sheet protection of course
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/12/2007 by Ibartlett
'

Application.ScreenUpdating = False

Sheets("Sorted_BedBoard_List").Select
Columns("A:G").Select
Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet1").Select
Range("D5").Select
Application.ScreenUpdating = True

End Sub
Thanks for any help
Bart



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default protect unprotect sheet vba

Ian,

try this:-

Sub standard()
Application.ScreenUpdating = False

With Sheets("Sorted_BedBoard_List")
.Select
.Unprotect Password:="CRU"
End With
Columns("A:G").Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet2").Select
Range("D5").Select
With Sheets("Sorted_BedBoard_List")
.Select
.Protect Password:="CRU"
End With
Application.ScreenUpdating = True

End Sub

Mike

"ian bartlett" wrote:

I'm hoping someone could help with this
'Sub sort()
''
'' sort Macro
'' Macro recorded 6/11/2007 by Ibartlett
'Const csPWORD As String = "CRU"
'ActiveWorkbook.Worksheets("Sorted_BedBoard_List") .Unprotect
Password:=csPWORD
'
'
' Sheets("Sorted_BedBoard_List").Select
' Columns("A:G").Select
' Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
' DataOption1:=xlSortNormal
' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
' Sheets("Sheet1").Select
' Range("D5").Select
' ActiveWorkbook.Worksheets("Sorted_BedBoard_List"). Protect
Password:=csPWORD
'
'End Sub

this doesn't work

this works but doesn't incorporate the sheet protection of course
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/12/2007 by Ibartlett
'

Application.ScreenUpdating = False

Sheets("Sorted_BedBoard_List").Select
Columns("A:G").Select
Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet1").Select
Range("D5").Select
Application.ScreenUpdating = True

End Sub
Thanks for any help
Bart




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default protect unprotect sheet vba

no need to select as far as i know

Sub Protect_All_Sheets()
Dim i As Long
For i = 1 To Worksheets.Count
With Worksheets(i)
.Protect
End With
Next

End Sub



--


Gary


"Mike H" wrote in message
...
Ian,

try this:-

Sub standard()
Application.ScreenUpdating = False

With Sheets("Sorted_BedBoard_List")
.Select
.Unprotect Password:="CRU"
End With
Columns("A:G").Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet2").Select
Range("D5").Select
With Sheets("Sorted_BedBoard_List")
.Select
.Protect Password:="CRU"
End With
Application.ScreenUpdating = True

End Sub

Mike

"ian bartlett" wrote:

I'm hoping someone could help with this
'Sub sort()
''
'' sort Macro
'' Macro recorded 6/11/2007 by Ibartlett
'Const csPWORD As String = "CRU"
'ActiveWorkbook.Worksheets("Sorted_BedBoard_List") .Unprotect
Password:=csPWORD
'
'
' Sheets("Sorted_BedBoard_List").Select
' Columns("A:G").Select
' Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
' DataOption1:=xlSortNormal
' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
' Sheets("Sheet1").Select
' Range("D5").Select
' ActiveWorkbook.Worksheets("Sorted_BedBoard_List"). Protect
Password:=csPWORD
'
'End Sub

this doesn't work

this works but doesn't incorporate the sheet protection of course
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/12/2007 by Ibartlett
'

Application.ScreenUpdating = False

Sheets("Sorted_BedBoard_List").Select
Columns("A:G").Select
Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet1").Select
Range("D5").Select
Application.ScreenUpdating = True

End Sub
Thanks for any help
Bart






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default protect unprotect sheet vba

Mike H

Thank you very much that did the trick.

Ian

"ian bartlett" wrote in message
news:CFUbi.19823$NV3.7570@pd7urf2no...
I'm hoping someone could help with this
'Sub sort()
''
'' sort Macro
'' Macro recorded 6/11/2007 by Ibartlett
'Const csPWORD As String = "CRU"
'ActiveWorkbook.Worksheets("Sorted_BedBoard_List") .Unprotect
Password:=csPWORD
'
'
' Sheets("Sorted_BedBoard_List").Select
' Columns("A:G").Select
' Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes,
_
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
' DataOption1:=xlSortNormal
' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
' Sheets("Sheet1").Select
' Range("D5").Select
' ActiveWorkbook.Worksheets("Sorted_BedBoard_List"). Protect
Password:=csPWORD
'
'End Sub

this doesn't work

this works but doesn't incorporate the sheet protection of course
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/12/2007 by Ibartlett
'

Application.ScreenUpdating = False

Sheets("Sorted_BedBoard_List").Select
Columns("A:G").Select
Selection.sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet1").Select
Range("D5").Select
Application.ScreenUpdating = True

End Sub
Thanks for any help
Bart





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
Unprotect and Protect sheet within macro John F[_2_] Excel Programming 3 January 11th 05 04:49 PM
Unprotect and protect sheet in a macro Ola Sigurdh Excel Programming 1 September 28th 04 11:55 PM
Excel VBA-Protect and unprotect sheet with BVA marfrk Excel Programming 1 May 3rd 04 12:37 PM
Protect/unprotect sheet with password with VBA? dragontale[_7_] Excel Programming 1 April 19th 04 09:29 PM
VBA code - protect and unprotect a sheet Jeff Excel Programming 2 December 2nd 03 11:44 PM


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