Using Excel Shared Workbook with VBA code applied to 12 Worksheets

  • I have a shared workbook which has 12 worksheets and each Worksheet has to following VBA code to lock cells after data entry:

    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim cl As Range


    For Each cl In Target

    If cl.Value <> "" Then

    check = MsgBox("is this entry correct? This cell cannot be entered after entering a value.", vbYesNo, "Cell Lock Notification")

    If check = vbYes Then

    cl.Locked = True


    cl.Value = ""

    End If

    End If

    Next cl


    End Sub

    This works fine when the Workbook is not shared, but when I Share the workbook the code doesn't perform (doesn't run). My question is, "is in possible to share a Wordbook and the code will run as intended?" Meaning that after data is entered the cell is automatically locked, so other cannot either enter data or delete data. I know that the codes cannot be viewed or edited in the shared workbook.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!