Results 1 to 16 of 16

Thread: VBA Lock rows upon checkbox click on multi-sheets

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Exclamation VBA Lock rows upon checkbox click on multi-sheets

    Hi guys,

    I would like to make a code in VBA that locks the entirerow whenever the checkbox is checked on both sheet 1 (starting from row 3), sheet 2 (starting from row 4). What I did now was using the code below on sheet 2, and using formular [=IF('sheet 2 defined cell value <>"", "1","")] on sheet 1 to try to prompt the same code with another private sub. But apparently that doesn't work as planned and the code below isn't perfect as well. Please comment below for any ideas!!! Thank you guys!

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim a As Long
    
    
        If Not Intersect(Target, Columns("P")) Is Nothing Then
            ' the changed cell is in column P
            If Target.Cells.Count = 1 Then
                ' only act if it is a single cell, so multicell copy will not trigger this
                If Target.Value <> "" Then
                    Me.Unprotect Password:="123"
                    Target.EntireRow.Locked = True
                    Me.Protect Password:="123"
                Else
                    Me.Unprotect Password:="123"
                End If
            End If
        End If
    End Sub
    Last edited by Paul_Hossler; 04-02-2019 at 05:21 AM. Reason: CODE Tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •