VBA lock an active row

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I would like to after an active row has been filled that VBA will automatically locks that row from being changed in the future.

Can someone help me with this coding?

Thanks,
Pinaceous
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I think you will need to define what it means to "be filled".
Namely, which column(s) need to be filled?
Also, how exactly are these columns being filled? Manually? By copy/paste? By formula?
 
Upvote 0
Hi Joe,

Thanks for responding.

Okay, I have Sheet1 whereby I have a user filling in one row starting from row's 7 - 21 from Columns A to L.

I would like when the user has completed their row that that row then becomes locked in not allowing the next user to tamper with its information that was written there.


Thank you,

Paul
 
Upvote 0
Yes, each user will fill out one of these (their) row "starting from row's 7 - 21 from Columns A to L".

At this point in time this is not a shared document, so each user will have the opportunity to input information exclusively.
 
Upvote 0
Maybe something like the selection_change event macro below. This would handle inadvertent changing of another user's row. Would need some adjustment to prevent willful changes while still permitting a legitimate user to edit his row after filling in all the cells.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range, R As Range, ans As Long
Set R = Range("A7:L21")
For Each c In Target
    If Not Intersect(c, R) Is Nothing Then
        If Application.CountA(R.Rows(c.Row - R.Rows(1).Row + 1)) = R.Columns.Count Then
            ans = MsgBox("Row " & R.Rows(c.Row - R.Rows(1).Row + 1).Row & " is filled and locked. If its your row, choose Yes to open it for editing", vbYesNo)
            If ans = vbYes Then Exit Sub
            Application.EnableEvents = False
            R(1, 1).Offset(-1, 0).Select
            Application.EnableEvents = True
            Exit Sub
        End If
    End If
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,178
Members
452,615
Latest member
bogeys2birdies

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