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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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