A VBA code to create and protect a sheet with password

seragrefaat

Board Regular
Joined
Nov 16, 2020
Messages
53
Office Version
  1. 365
Platform
  1. Windows
I have this code modified by member Fluff, and i want to add to it a code for protecting every sheet created with a password. this is the code:
Also I want a code to print the created sheets, but not in the same code that creates and renames them, a different code which i will add it to a command button placed in the Sheet Data.
Thanks in advance

VBA Code:
Private Sub CommandButton1_Click()
   Dim cl As Range
   
   Application.ScreenUpdating = False
   With Sheets("Data")
      For Each cl In .Range("Q4", .Range("Q" & Rows.Count).End(xlUp))
         If cl.Value <> "" Then
            Sheets("Template").Copy , Sheets(Sheets.Count)
            ActiveSheet.Name = cl.Value
            ActiveSheet.Range("E4").Value = cl.Value
            ActiveSheet.Range("B39").Value = cl.Offset(, 1).Value
            .Hyperlinks.Add cl, "", "'" & cl.Value & "'!A1", cl.Value
            
         End If
      Next cl
   End With
   Application.ScreenUpdating = True
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top