Aug 23 2023 11:01 PM
Tech Community,
I need one help, I have a main template from which I'm going generate one customer copy.
while generating customer copy I need to hide column B:G of each sheet in customer copy, as these columns are hidden in customer copy and if I need to unhide them then it should request a password without which it should not unhide. Can someone help me out in this.
attached sample template as detailed one not able to share.
@Hans Vogelaar can you please help me?
Aug 24 2023 12:11 AM
If you want to require a password to unhide columns, you will have to do the following:
Would that be OK?
Aug 24 2023 12:27 AM
As a comment, all information into the hidden columns of the protected sheet could be available to users without password. For example, it's enough in any unprotected cell to enter =B1 and drag to the right and down.
Aug 24 2023 01:56 AM - edited Aug 24 2023 02:23 AM
@Hans Vogelaar Requirement is that column should get hide while creating a customer copy from main template.
Main template already have vba code that is developed to meet other functionality requirements hide columns is new additional requirement.
Aug 24 2023 02:00 AM
Aug 24 2023 02:24 AM
@Sumit_Bhokare , I see, thank you
Aug 24 2023 02:56 AM
SolutionSub CreateCopy()
Dim wsh As Worksheet
Dim fil
For Each wsh In Worksheets
wsh.Range("B1:G1").EntireColumn.Hidden = True
Next wsh
fil = Application.GetSaveAsFilename( _
InitialFileName:="New Workbook", _
FileFilter:="Excel Macro-enabled Workbook (*.xlsm),*.xlsm", _
Title:="Create copy of workbook")
If fil = False Then
Beep
Else
ActiveWorkbook.SaveCopyAs fil
End If
For Each wsh In Worksheets
wsh.Range("B1:G1").EntireColumn.Hidden = False
Next wsh
End Sub
Aug 24 2023 04:13 AM
Aug 24 2023 04:28 AM
See my first reply.
Aug 24 2023 02:56 AM
SolutionSub CreateCopy()
Dim wsh As Worksheet
Dim fil
For Each wsh In Worksheets
wsh.Range("B1:G1").EntireColumn.Hidden = True
Next wsh
fil = Application.GetSaveAsFilename( _
InitialFileName:="New Workbook", _
FileFilter:="Excel Macro-enabled Workbook (*.xlsm),*.xlsm", _
Title:="Create copy of workbook")
If fil = False Then
Beep
Else
ActiveWorkbook.SaveCopyAs fil
End If
For Each wsh In Worksheets
wsh.Range("B1:G1").EntireColumn.Hidden = False
Next wsh
End Sub