Blocking cells for certain users

miguelg8

New Member
Joined
Oct 16, 2009
Messages
3
Is there any way to block editing cells or columns for certain users?
Let's say i want:
John to edit column A
Peter to edit Column B
Peter and John column C.

Is this possible? I don't know the information they are entering, so i can't restrict the content, but want to restrict the lines they can edit.

Thanks!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Welcome to teh Board!!!

The only way I can think of to do this is to use VBA. In the Close event of the workbook, you would lock all cells on the worksheet, and protect the sheet. In the Open event of the workbook, you then use Environ("USERNAME") to determine the username of the person logged in, and unlock the appropriate cells based on the return value.
 
Upvote 0
Hatman is correct in assuming you will need VBA. There are, however, several approaches, including his suggestion of using Environ("UserName"). This.however, is my approach
Code:
Private Sub Worksheet_Change(Byval Target as Range)
Select Case Target.Column
Case 1:
    If InputBox ("Enter password") <> "passwordA" Then
        MsgBox "Wrong password"
        Application.Enable.Events = False
        Application.Undo
        Application.EnableEvents = True
    End If
Case 2
   'similar code
'etc
Case Else:
End Select
End Sub

lenze
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

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