A situation arises when we need to give access to specific cells of a shared excel file depending on UserId.
VBA code for this mentioned below:
Sub specificAccesstocellsinWorksheet()
If Environ("COMPUTERNAME") = "SOUM-BJS" Then
ActiveSheet.Unprotect
ThisWorkbook.Sheets(1).Range("B1:B21").Locked = False
ActiveSheet.Protect
End If
End Sub
VBA code for this mentioned below:
Sub specificAccesstocellsinWorksheet()
If Environ("COMPUTERNAME") = "SOUM-BJS" Then
ActiveSheet.Unprotect
ThisWorkbook.Sheets(1).Range("B1:B21").Locked = False
ActiveSheet.Protect
End If
End Sub
No comments:
Post a Comment