Hide different range of columns with password when protected copy is created

Viewed 34

I have to create a protected sheet from a master excel. But now, before sharing protected sheet with 3rd party user, I have to hide few columns [Column 1 (A), Column 2 (B) and everything from column 43 - 92 (AQ to CN)] in the generated protected sheet and this should be password enabled. that is people shouldn't be able to unhide columns. So, when I receive the file back from them with their updates, I should be able to unhide these sheets using the password. How can I do that ensuring above columns are password enabled hidden when protected sheet is generated? My attempts below.

If Sheet2.Cells(1, i).Value = "Exclusions" Then 
    Sheet2.Columns(i).Hidden = True 
End If

Repeating the above for all the column headers. This is extremely time consuming and lengthy.

Next is something I found online but did not work for me as I was creating a Sub within Sub.

Sub HideCols() 
    For i = 1 To ActiveSheet.UsedRange.Columns.Count 
        If Lcase (Cells(2, i).Value) = "Exclusions" Then Columns(i).Hidden = True 
    Next 
End Sub
0 Answers
Related