Using Excel Shared Workbook with VBA code applied to 12 Worksheets

Lobo1943

New Member
Joined
Aug 22, 2017
Messages
6



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

ActiveSheet.Unprotect

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

Else

cl.Value = ""

End If

End If

Next cl

ActiveSheet.Protect


End Sub

The work fine when the Workbook is not shared, but when I Share the workbook the code doesn't perform. My question is, "is in possible to share a Wordbook and the code will perform as intended?" Meaning that after date is entered the cell is automatically locked, so other cannot either enter data or delete data.
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Watch MrExcel Video

Forum statistics

Threads
1,095,752
Messages
5,446,294
Members
405,395
Latest member
anilals

This Week's Hot Topics

Top