#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Row Protection

Dear experts,

In a worksheet, from A2 to E200 is the range for users to fill in. Each row
is an application record and users will fill into it. I will approve each
record in column F by a word "approved". After I entered this word and saved
the file, I want that record and above record(s) will be protected by a
password "done" so that no users can edit the details of approved records
anymore except me. Is it require a VBA code? If yes, please advise what is
the code.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,071
Default Row Protection

Yes, it will require VBA. The following macro will do what you want. I
assumed that row 1 contains your headers. This macro must be placed in the
ThisWorkbook module. I assumed that the sheet in question is named
"MySheet". Change this in the code as needed. Note that this macro does
the following in order:
Unprotects the sheet, password "Done".
Unlocks every cell in the sheet.
Locks every cell in every row that contains "Approved" in Column F.
Protects the sheet, password "Done".
I strongly recommend that you use Data Validation in Column F and have
"Approved" as the only allowed selection. This will preclude any
misspellings or typos. HTH Otto
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim i As Range
Application.ScreenUpdating = False
Sheets("MySheet").Select
ActiveSheet.Unprotect Password:="Done"
ActiveSheet.Cells.Locked = False
Range("A1:F200").AutoFilter
Range("A1:F200").AutoFilter Field:=6, Criteria1:="Approved"
On Error GoTo NoApproved
For Each i In Range("A2:F200").SpecialCells(xlCellTypeVisible)
i.EntireRow.Locked = True
Next i
NoApproved:
On Error GoTo 0
Range("A1:F200").AutoFilter
ActiveSheet.Protect Password:="Done"
Application.ScreenUpdating = True
End Sub
"Freshman" wrote in message
...
Dear experts,

In a worksheet, from A2 to E200 is the range for users to fill in. Each
row
is an application record and users will fill into it. I will approve each
record in column F by a word "approved". After I entered this word and
saved
the file, I want that record and above record(s) will be protected by a
password "done" so that no users can edit the details of approved records
anymore except me. Is it require a VBA code? If yes, please advise what is
the code.

Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Row Protection

Thanks Otto. Best regards.

"Otto Moehrbach" wrote:

Yes, it will require VBA. The following macro will do what you want. I
assumed that row 1 contains your headers. This macro must be placed in the
ThisWorkbook module. I assumed that the sheet in question is named
"MySheet". Change this in the code as needed. Note that this macro does
the following in order:
Unprotects the sheet, password "Done".
Unlocks every cell in the sheet.
Locks every cell in every row that contains "Approved" in Column F.
Protects the sheet, password "Done".
I strongly recommend that you use Data Validation in Column F and have
"Approved" as the only allowed selection. This will preclude any
misspellings or typos. HTH Otto
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim i As Range
Application.ScreenUpdating = False
Sheets("MySheet").Select
ActiveSheet.Unprotect Password:="Done"
ActiveSheet.Cells.Locked = False
Range("A1:F200").AutoFilter
Range("A1:F200").AutoFilter Field:=6, Criteria1:="Approved"
On Error GoTo NoApproved
For Each i In Range("A2:F200").SpecialCells(xlCellTypeVisible)
i.EntireRow.Locked = True
Next i
NoApproved:
On Error GoTo 0
Range("A1:F200").AutoFilter
ActiveSheet.Protect Password:="Done"
Application.ScreenUpdating = True
End Sub
"Freshman" wrote in message
...
Dear experts,

In a worksheet, from A2 to E200 is the range for users to fill in. Each
row
is an application record and users will fill into it. I will approve each
record in column F by a word "approved". After I entered this word and
saved
the file, I want that record and above record(s) will be protected by a
password "done" so that no users can edit the details of approved records
anymore except me. Is it require a VBA code? If yes, please advise what is
the code.

Thanks in advance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
WS Protection: Different Levels of Protection on Different Ranges Carmi Excel Discussion (Misc queries) 4 August 31st 07 02:26 PM
Cell Protection vs. Worksheet Protection kmwhitt Excel Discussion (Misc queries) 4 September 24th 06 02:37 AM
Worksheet protection is gone and only wokbook protection can be se Eric C. Excel Discussion (Misc queries) 4 May 2nd 06 04:50 PM
Protection HDV Excel Discussion (Misc queries) 1 March 25th 06 07:46 PM
Protection Gene Excel Discussion (Misc queries) 1 October 25th 05 04:17 PM


All times are GMT +1. The time now is 11:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"