locking columns

arnoldmiranda

Board Regular
Joined
Jul 15, 2002
Messages
233
Hi,
I need help with an excel file, the file contains certain parameters from A5 to A15 in B6 we type the agent name and below that if he/she passed or failed in the parameters listed in column A2 to A15 subsequently for every other agent we will capture similar data in column C,D etc
While updating an agents entry in column C it's imperative that no changes are made in column B etc once the data has been entered
Can a macro be written which will lock the entire columnB when an entry is made in cell B15, etc etc

thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Put the following in theVBA Objects Sheet that you want to protect. when something is put into row 15, it will unprotect the sheet, change the locked indicator for that column to TRUE; then re-protect the sheet. The column will now be locked. I used "asdf" as the password, change it to whatever you want.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 15 Then
ActiveSheet.Unprotect "asdf"
Columns(Target.Column).Locked = True
ActiveSheet.Protect "asdf", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,122
Messages
6,164,084
Members
451,872
Latest member
TimothyLynn

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