Forum Discussion
Sumit_Bhokare
Aug 24, 2023Brass Contributor
Column hide & to unhide column password is required
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, ...
- Aug 24, 2023
Sub 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
Sumit_Bhokare
Aug 24, 2023Brass Contributor
HansVogelaar 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.
HansVogelaar
Aug 24, 2023MVP
Sub 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- Sumit_BhokareAug 24, 2023Brass ContributorHansVogelaar Can we add fixed password which will unhide columns?
- HansVogelaarAug 24, 2023MVP
See my first reply.