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.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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