Help with formula:

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I got the following formula from this newsgroup.

Private Sub Workbook_Open()
Worksheets("Sheet1").Unprotect
With Worksheets("Sheet1").Range("A1")
.Value = .Value + 1
End With
Worksheets("sheet1").Protect Scenarios = True
UserInterfaceOnly = True
End Sub
This formula is supposed to add a sequential number, when
this file is opened. Two problems I have is that the
number does not change when the files is opened and that
I only need one cell protected not the entire worksheet.
Any help with this formula would be greatly appreciated

Thanks,
Brian
 
Hi Brian
You may check the following
1. First (as I mentioned in my previous post) you have to uncheck the
protection for all other cells in your sheet (select the cells goto
'format - cells' -> choose the tab 'protection' and uncheck the
protection: Alternatively select the entire sheet and uncheck the
protection for all cells. Afterwars just select the single cell and
re-check the protection
2. Make sure that your sheet is named 'Sheet1' or change the name of
the sheet in the procedure accordingly
3. Make sure to put this code in the workbook module of your workbook
(Right click on the Excel symbol left to the menu entry 'File', choose
code and paste the code below)
4. The lines
Worksheets("sheet1").Protect Scenarios = True
UserInterfaceOnly = True
are actually one singled line (word wrapping of the newsreader)

HTH
Frank
 
I have excel 2000. When I go to format -cells- Protection
tab I get the boxes locked and hidden, the locked box is
checked. Also where do i input a password for protecting
the cells?
 
Hi
uncheck the 'lock' checkmark. The password can be entered then
protecting the whole worksheet ('Data - Protection')
Frank
 
Back
Top