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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

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