PC Review


Reply
Thread Tools Rate Thread

Auto sorting? Auto lock?

 
 
David Stricklen
Guest
Posts: n/a
 
      11th Mar 2008
I have a worksheet in which I enter data under 8 titled columns. After entering info on the 8th and final column, I would like for excel to sort by column 1, which is the date, and also lock the row, say row 24, preventing mistakes on previously entered transactions. If anyone knows how to help, I would definitely appreciate it.

David
 
Reply With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      12th Mar 2008
David
You will need a sheet event macro. The macro below will work with the
8th column being Column H, headers in row 1, and data starting in row 2.
You will need to unlock all the cells in the 8 columns for as many rows as
you think you might have data in the future. If you have data in only the 8
columns in the sheet, it would be simpler to unlock all the cells in the
sheet.
If you have some data already in those 8 columns that you want to "lock",
simply select all those cells and lock them. Be aware that
locking/unlocking a cell does nothing, by itself, to protect that cell. The
sheet must be protected as well. With the sheet protected, access to change
the contents of a cell will be denied ONLY if that cell is locked.
You need to protect the sheet.
Once you have done all the above, install the macro below.
The macro below will do the following:
The macro will fire with a change to the contents of any cell in the sheet.
If the changed cell (the "Target" cell) is not in Column H, the macro will
do nothing.
If the target cell is in Column H, the macro will:
Lock the cells in that row in all 8 columns.
Sort all the data in those 8 columns by Column A.
Done.
Note that this macro must be placed in the sheet module of that one specific
sheet. To access that module, right-click on the sheet tab, and select View
Code. Paste this macro into the displayed module. "X" out of the module to
return to your sheet. Post back if you need more. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("H:H")) Is Nothing And _
Target.Row > 1 Then
Dim RngToSort As Range
ActiveSheet.Unprotect
Range(Cells(Target.Row, 1), Cells(Target.Row, 8)).Locked = True
Set RngToSort = Range("A1", Range("A" &
Rows.Count).End(xlUp).Offset(, 7))
Application.EnableEvents = False
RngToSort.Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Application.EnableEvents = True
ActiveSheet.Protect
End If
End Sub
"David Stricklen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
I have a worksheet in which I enter data under 8 titled columns. After
entering info on the 8th and final column, I would like for excel to sort by
column 1, which is the date, and also lock the row, say row 24, preventing
mistakes on previously entered transactions. If anyone knows how to help, I
would definitely appreciate it.

David


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Logon AND auto lock workstation? John Dalberg Windows XP Help 3 9th Nov 2006 12:19 AM
Auto resize, auto realign, auto ANYTHING driving me crazy spasmous@yahoo.com Microsoft Powerpoint 2 30th Apr 2005 02:14 AM
Auto Lock =?Utf-8?B?TWFyeg==?= Windows XP Security 1 3rd Jun 2004 06:33 AM
auto lock out Little Judy Microsoft Windows 2000 3 31st Jan 2004 10:22 PM
Auto Lock Tim Hockensmith Microsoft Windows 2000 2 5th Dec 2003 07:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:23 PM.