Unlock cells after data entry

Spes_

New Member
Joined
Oct 22, 2018
Messages
4
Hi all,

I was wondering how to unlock cells after certain data was entered, e.x required fields are A1 B1, F1.

Once there are values in those fields the next row will become editable and so on...

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Example below unlocks columns A to J in the active row if previous row columns A,B and F all contain some value
- amend the password and the cells to be unlocked to match your requirements

Goes in sheet module (right-click on sheet tab \ View Code \ paste VBA into that window \ {ALT}{F11} takes you back to Excel

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim r As Long:    r = Target.Row
    If r = 1 Then Exit Sub
    
    Me.Unprotect "password"
    If Cells(r - 1, "A") <> "" And Cells(r - 1, "B") <> "" And Cells(r - 1, "F") <> "" Then
        Cells(r, "A").Resize(, 10).Locked = False
    End If
    Me.Protect "password"
End Sub
 
Last edited:
Upvote 0
Please ignore suggestion in post#2

On second thoughts, this is a better approach
- frees up the first 10 columns in next row as soon as there is a value in all 3 cells in the current row

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Long:    r = Target.Row
    If Cells(r, "A") <> "" And Cells(r, "B") <> "" And Cells(r, "F") <> "" Then
        Me.Unprotect "password"
        Cells(r + 1, "A").Resize(, 10).Locked = False
        Me.Protect "password"
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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