How to protect a row of data once information is confirmed

SCOTLAND

New Member
Joined
Apr 16, 2004
Messages
1
How do I go about protecting a row of data automatically once it has been confirmed as accurate? I'll explain a bit of what I'm looking for. Several users currently enter data to a shared spreadsheet. That data is verified in accounting and once done so the row is marked with an "x" to indicate agreement and posting to the GL. How would I get Excel to automatically password protect these rows marked with the "x" upon exiting the file. Any suggestions?? I don't want to manually select rows. Thanks.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi - Welcome to the board

Try this before save code. You can do it for before close, but you would have to save to make sure the changes were kept.

Code:
Option Explicit

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim x As Long
Dim y As Long

    Sheets("Sheet1").Unprotect Password:="Password"
    y = Sheets("Sheet1").Range("A65536").End(xlUp).Row
    For x = 1 To y
        If Range("A" & x).Value = "x" Then Range("A" & x).EntireRow.Locked = True
    Next x
    Sheets("Sheet1").Protect Password:="Password"

End Sub
 
Upvote 0
Re: How to protect a row of data once information is confirm

there must be data in column A, else change the code
this code locks the last row and if you want unlocks the following row
so there will only be one row where data can be put in
Code:
Sub protectlastrow()
ActiveSheet.Unprotect
Range("A65536").End(xlUp).EntireRow.Locked = True
Range("A65536").End(xlUp).Offset(1, 0).EntireRow.Locked = False
ActiveSheet.Protect
End Sub
regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,223,920
Messages
6,175,377
Members
452,638
Latest member
Oluwabukunmi

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