Posts

Showing posts from May, 2013

Excel Macro - Some Useful VBA Codes

To Protect All Sheets at once( but want to use Auto filters, sorting, pivot tables, formatting cells, etc) Sub Protectallsheets() Dim S As Worksheet For Each S In ThisWorkbook.Sheets S.Protect Password:="give your password", DrawingObjects:=False, Contents:=True, Scenarios:= _       False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _       AllowFormattingRows:=True, AllowInsertingHyperlinks:=True, AllowSorting:=True, _       AllowFiltering:=True, AllowUsingPivotTables:=True Next End Sub Tips: - If you want some of your sheets to not be protected in that worksheet then put the following codes above the line “Next” Sheet sheet number .Unprotect Password:="give your password" Sheet sheet number .Unprotect Password:="give your password" Sheet sheet number .Unprotect Password:="give your password" To Un Protect All Sheets at once Sub UnProtectAllsheets() Dim S As Worksheet For Each S I