Nick, here is some code, to put in this macro right click on the worksheet
tab and view code, in the
window that opens paste this code, press Alt and Q to close this window and
go back to your workbook.
Private Sub Worksheet_Activate()
Dim strPassword As String
On Error Resume Next
Me.Protect Password:="123"
Me.Columns.Hidden = True
strPassword = InputBox("Enter password to view this sheet")
If strPassword = "" Then
Me.Previous.Select
Exit Sub
ElseIf strPassword <> "123" Then
MsgBox "Password Incorrect "
Me.Previous.Select
Exit Sub
Else
Me.Unprotect Password:="123"
Me.Columns.Hidden = False
End If
On Error GoTo 0
End Sub
Private Sub Worksheet_Deactivate()
On Error Resume Next
Me.Columns.Hidden = True
On Error GoTo 0
End Sub
Be aware that sheet passwords are very easy to break and all somebody would
have to do is open the workbook with macros disabled unprotect the sheet and
then unhide the columns to see your data, this will keep out some people but
if somebody wants to see your data in Excel they will find a way, Excel is
not a secure platform.
You will also need to protect the VBA project so people can't see the
password from there.
To protect the VBA project, from your workbook right-click the workbook's
icon and pick View Code. This icon is to the left of the "File" menu this
will open the VBA editor, in the left hand window right click on your
workbook name and select VBA project properties, protection, check lock
project for viewing and set a password. Press Alt and Q to close this window
and go back to your workbook and save and close the file. Be aware that this
password can be broken by third party software
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003