Skip to main content

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”

Sheetsheet number.Unprotect Password:="give your password"
Sheetsheet number.Unprotect Password:="give your password"
Sheetsheet number.Unprotect Password:="give your password"


To Un Protect All Sheets at once

Sub UnProtectAllsheets()
Dim S As Worksheet
For Each S In ThisWorkbook.Sheets
S.Unprotect Password:="give your password"
Next
End Sub

Comments

Popular posts from this blog

Password Protect your USB Flash Drive without any software....

I was trying to protect my USB flash drive from a long time but didn’t find anything nice. Almost all the software were either not giving full features or were asking for money to do so and give full benefits. One software called Truecrypt was nice but not giving me simple password protection feature. Anyways, now I submit one good info with all who want to simply password protect their USB flash drive / pen drive without all unnecessary softwares. Steps to protect your USB flash drive 1.       Insert your pendrive. 2.       Open the drive 3.       Create a folder (lets name is ABCD) and keep all your data in it. (You can partially protect this disk too by moving your important / secure data only into this folder) 4.       Remember a password. Lets name is 12345 5.       Now open a note pad and copy and paste the following text into it: -...

Difference Between Consignment And Sales

Consignment can not be treated as sales of goods. It is different from sales. The difference between consignment and sales are as follows: 1. Ownership Consignment: The ownership of the goods remains with the consignor until sales is effected by the consignee. Sales: The ownership of the goods immediately transferred to the buyer when sale is effected. 2. Relationship Consignment: The relationship between the consignor and consignee are of principal and agent. Their relation ship are continued till terminated. Sales: The relationship between the two parties are that of seller and buyer and they terminated as soon as payment is made and goods are delivered. 3. Expenses Consignment: The expenses incurred by the consignee to execute sale and the expenses incurred by consignor to send the goods to the consignee, both are borne by the consignor. Sales: Any expenses incurred after the sale is not borne by the seller. 4. Risk Consignment: The risk of goods under c...

Sai Sampurna Padhi - A Sweet Bubbly Girl fighting for her life at Cuttack

Hello Everyone, Today I want to share with you all about a girl named "Sai Sampurna Padhi" Some details of this girl: - Name                   : - Sai Sampurna Padhi Age                       : - 2.5 Years Residence           : - Bidanasi, Cuttack, Odisha Father's Name    : - Linku Padhi Mother's Name   : - Chandrika Mohapatra Father's Occupation    : - Auto Driver at Badambadi Bus Stand, Cuttack This girl is admitted to SCB Medical College because she is suffering from a very dangerous disease called "Blood Cancer" and as its at Stage-I doctors has prescribed to go for Bone Marrow transplant as soon as possible so that this can be cured. But the operation cost around 20-25 Lacks which they can't arrange. For the time being, every week she has need of blood, plasma, test & medicine which is less as it is a government ho...