Code not workig in shared mode

ObiJuan

New Member
Joined
Jan 13, 2010
Messages
5
Hello,

I have a spreadsheeet that's used as a sign-up sheet. The goal is for a user to be able to enter data (their name) into a cell, then lock it to prevent another user from making changes to that same cell. My code works perfectly until I share the workbook. When it's shared, it seems to completely ignore the events. And since it's shared, the code is locked, making it impossible to step though.

Does anyone have any suggestions on how I can get the code to work in shared mode? Or is there another way to restrict data after the first entry?

Thanks in advance,
Omar

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)



Application.DisplayAlerts = False

If Target.Value = Empty Then

ActiveSheet.Unprotect

Else:

ActiveCell.Locked = True

ActiveSheet.Protect

End If
Application.DisplayAlerts = True


End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Here's the rest of the code

Code:
Private Sub Worksheet_Activate()

Application.EnableEvents = True

End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo error:
Dim rng As Range

With ActiveSheet
    .Unprotect

'Only for certain columns and rows
If Target.Column > 1 And Target.Column < 10 Then

    If Target.Row > 85 Then

        Target.Clear
        Exit Sub
    End If

Else: Target.Clear
    Exit Sub
End If


    .Unprotect
    If Target.Value <> Empty Then Target.Locked = True
    .Protect
End With
error:

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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