View Single Post
  #2   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi

I use a procedure which makes various adjustments on protected sheet. The
procedure is started by user from button on one worksheet, but the same code
can be implemented into workbooks Open event too.

On worksheet with data, in one column the user can mark rows to be deleted.
Whenever the adjustments procedure is running, all marked rows are deleted.
The example of code is below:
-------
Public Sub AdjustTables()

' remove sheets protection
Sheets("Sheetname").Unprotect Password:="password"
...
' Adjusting table MyTable
...
' Reading named constants
...
varDate0 = [Date0]
varFix = [Fix]
varHeaderRows = [HeaderRows]
varEntries=[Entries]
...
Worksheets("Sheetname").Activate

' sorting table
...
' removing rows marked for deleting, counting rows to be moved to
arvhive
' rows with is TRUE in column N are deleted
i = 1
varArhivate = 0
Do Until i varEntries
If Worksheets("Sheetname").Range("N" & (varHeaderRows + i)) Then
Worksheets("Sheetname").Rows((varHeaderRows + i) & ":" &
(varHeaderRows + i)).Delete Shift:=xlUp
varUsedRows = [UsedRows]
varTotalRows = [TotalRows ]
varEntries= [Entries]
Else
If Worksheets("Sheetname").Range("B" & (varHeaderRows +
i)).Value < varDate0 Then varArchivate = i
i = i + 1
End If
Loop
...
' replacing formulas from rows older as varFix days with values
...
' mowing rows older as varDate0 to archive
...
' adding new rows from last entry until today with default values
...
' adding or removing empty rows with prepared formulas at end of tablel
...
' redefining named range tblMyTable
...
' protecting sheets
...
Sheets("Sheetname").Protect Password:="password",
UserInterfaceOnly:=True
Sheets("Sheetname").EnableAutoFilter = True
...
End Sub
-------

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets



"Beisaikong" wrote in message
...
i locked certain cells in my excel worksheet ... and for the locking to

work
... i need to protect the document ...

in the protect options ... i allowed deletion of rows ...

but then ... when i try to delete after protecting the document ... it

will
say "cannot delete rows with locked cell"

anyone knows how to resolve ?!?!?!?!?!