thanks pjoaquin. Its working in that sheet. But I am getting the other problem related to the same issue in the same workbook.
I have used some code code to the whole workbook so that during opening this workbook you are asked to give your name. I have used the below code:-
Private Sub Workbook_Open()
'Prompt for name
Dim Ans As Variant
Ans = InputBox("Please enter your name.")
'Close the file if no name entered
If Ans = "" Then ThisWorkbook.Close False
'Enter name and date in the sheet
With Worksheets("Main Sheet")
.Range("B2") = Ans
.Range("C2") = Format(Now, "m/d/yyyy h:mm")
End With
End Sub
Now the same value ( name of the person who opens this workbook) & date with time will be autometically written in the B2 & C2 cell of my Main sheet.Main sheet is also protected by password "007" & only blue colored cells are unprotected for feeding the date. Now when I open this workbook then error is coming in this .Range("B2") = Ans (bold & underlined in the code). But when I add
ActiveSheet.Unprotect Password:="007"
&
ActiveSheet.Protect Password:="007"
in the above code then its working but all the cells in main sheet are getting unlocked.
I have given a screen picture of my main sheet. COULD ANYONE HELP ME PLEASE.
Bookmarks