Protect sheet except for input columns

AlEsp08

New Member
Joined
Jul 24, 2017
Messages
2
Hi! I need to protect the sheet except for specific columns where input is still needed based on the current month. Columns N to Y represents the months January to December. So, columns T to Y (July to December) need to be active because those months are still coming. When the month of August starts, input for July (column T) will automatically lock.

Also, try to avoid using the year in the formula because spreadsheet will be used for next year.

Thank you in advance!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hey AlEsp08 & welcome to the board

I don't think you can achieve this task without VBA. If you wish to use VBA, you can place the below code in VBE under Microsoft Excel Objects > ThisWorkbook & it will check for this upon opening the file (of course macros have to enabled)

Code:
Private Sub Workbook_Open()

Dim Period As Byte
Period = Month(Date)

Sheets("Sheet1").Unprotect Password:="test" 
Columns("N:Y").Locked = True

Select Case Period
    Case Is = 1: Columns("N:Y").Locked = False
    Case Is = 2: Columns("O:Y").Locked = False
    Case Is = 3: Columns("P:Y").Locked = False
    Case Is = 4: Columns("Q:Y").Locked = False
    Case Is = 5: Columns("R:Y").Locked = False
    Case Is = 6: Columns("S:Y").Locked = False
    Case Is = 7: Columns("T:Y").Locked = False
    Case Is = 8: Columns("U:Y").Locked = False
    Case Is = 9: Columns("V:Y").Locked = False
    Case Is = 10: Columns("W:Y").Locked = False
    Case Is = 11: Columns("X:Y").Locked = False
    Case Is = 12: Columns("Y:Y").Locked = False
End Select
    
Sheets("Sheet1").Protect Password:="test"

End Sub

Let me know if this works out for you
 
Upvote 0
Thank you for the reply mse330! I've been using Excel for a long time but I've always avoid using VBA even if using a long formula but in this case I have no choice.

Some additional questions:
1. I have replaced "Sheet1" with the name of my sheet. Is this correct?
2. After putting in the code, should I go back to my sheet and click 'Protect Sheet' for this to work?
3. Do you mind to hand out your email address so I can send you the file I am working on?
 
Upvote 0
Thank you for the reply mse330! I've been using Excel for a long time but I've always avoid using VBA even if using a long formula but in this case I have no choice.

Some additional questions:
1. I have replaced "Sheet1" with the name of my sheet. Is this correct?
2. After putting in the code, should I go back to my sheet and click 'Protect Sheet' for this to work?
3. Do you mind to hand out your email address so I can send you the file I am working on?

Yes, you are correct you need to change the "sheet1" with your sheet name ... I am already including in my code to protect the sheet afterwards so you don't have to do it manually.

I will PM you my email address shortly & you can send me the file
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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