How to lock hidden columns from end user

fvisions

Board Regular
Joined
Jul 29, 2008
Messages
191
Office Version
  1. 365
Platform
  1. Windows
Hello, I found these two from another post here and I was wondering if it would be possible to hide the given columns then lock them somehow so the person that receives the spreadsheet can not unhide them then when they fill out their columns it comes back to me and I unhide them for the final process of the data?

VBA Code:
Sub UnHide_Cells()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Range("B:C").EntireColumn.Hidden = False
Next ws
End Sub

VBA Code:
Sub Hide_Cells()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Range("B:C").EntireColumn.Hidden = True
Next ws
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try using the code below to lock...
VBA Code:
ActiveSheet.Protect Password:="Trixterz"

and unlock...
VBA Code:
ActiveSheet.UnProtect Password:="Trixterz"

More settings...
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, _
Password:=TokenKey, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFiltering:=True, AllowSorting:=True, AllowDeletingRows:=True, _
AllowInsertingRows:=True, AllowUsingPivotTables:=True, userinterfaceonly:=True
Sheets(SheetName).EnableSelection = xlNoRestrictions
 
Upvote 0
The project worked, the unproject I received an error 400
 
Upvote 0
The project worked, the unproject I received an error 400
I want the end user to be able to fill out the columns AB:AJ how to only hide and project from unhiding but allow them to enter information in the columns mentioned. You probably have it in the reference to your reply but I am a bit lost could you educate me a bit on this?
 
Upvote 0
I think I figured it out.

VBA Code:
Sub Hide_Cells()
Dim ws As Worksheet
Range("B1").Select
    ActiveCell.FormulaR1C1 = "."
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "."
    Range("H1").Select
    ActiveCell.FormulaR1C1 = "Current Equipment"
    Range("Q1").Select
    ActiveCell.FormulaR1C1 = "."
    Range("A1").Select
    
    Columns("B:AC").Select
    Selection.Locked = True
    Selection.FormulaHidden = False
    Columns("AD:AK").Select
    Selection.Locked = False
    Selection.FormulaHidden = False
       
    
For Each ws In ActiveWorkbook.Worksheets
ws.Range("B:f,H:j, L:O, Q:T").EntireColumn.Hidden = True
Next ws
ActiveSheet.Protect Password:="12121212"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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