Protection in Excel - how do i hide some info. from some users?

M

michael

I need to protect a workbook that will hide some of the information from
several users but will show this information to other users. it is very urgent
 
P

Peter Rooney

Michael,

Try something like this:

Sub Password()

Message = "Enter Password"
Title = "Restricted User Mode"
DefaultPassword = "********"
ReturnedPassword = UCase(InputBox(Message, Title, DefaultPassword))

If ReturnedPassword <> "MyPassword" Then
Exit Sub
Else
'Unprotect your ranges etc
End If

End Sub

On;y the prople who know "Mypassword" will be able to reveal the hidden
renges, columns, rows etc.

Hope this helps

Pete
 
M

michael

hi,

lets say i have a table o 5 coulmns:
A-E and i i have information in all the columns, but i whant that some of
the users will not be able to see the data in coulms D and E. how do i do
this.
 
M

michael

hi,

I reccive an error message in VB


Peter Rooney said:
Michael,

Try something like this:

Sub Password()

Message = "Enter Password"
Title = "Restricted User Mode"
DefaultPassword = "********"
ReturnedPassword = UCase(InputBox(Message, Title, DefaultPassword))

If ReturnedPassword <> "MyPassword" Then
Exit Sub
Else
'Unprotect your ranges etc
End If

End Sub

On;y the prople who know "Mypassword" will be able to reveal the hidden
renges, columns, rows etc.

Hope this helps

Pete
 
P

Peter Rooney

Michael,

It really all depend on how secure you want your columns to be.

You could hide the columns with the following:

Columns("D:E").EntireColumn.Hidden = true

and use the opposite command to unhide them in the macro I gave you earlier:

Columns("D:E").EntireColumn.Hidden = false

But this doesn't stop a user from manually unhiding the columns.

To counteract this, you could hide the column headers thus:

ActiveWindow.DisplayHeadings = False

but this doesn't stop somebody from redisplaying them via Tools-Options-View!

To really go for it, you have to have a macro that runs as soon as you open
your workbook that hides the columns, then customizes the menu to remove the
"Tools" command!

Somthing like this, perhaps:

Private Sub Workbook_Open()
ScreenSetup '(this can be anything - it's just the name of a procedure
you call)
End Sub

This goes in the "ThisWorkBook" code sheet, with ScreenSetup containing all
the procedures you need to customise your worksheet.

You need to remember to reset all the Excel settings you've changed before
you close the workbook, with the following macro that also goes in the
ThisWorkBook code sheet.

Private Sub Workbook_BeforeClose(cancel As Boolean)
ScreenReset '(this too can be anything - it's just the name of your
procedure)
End Sub

Try recording yourself changing the display and menu to your requirements
and pasting the resulting code into the two macros above, and opening and
closing your workbook to see what happens.

Hope this helps

pete
 
M

michael

thanks but this is not what i need, i need the users not to see in specific
columns and specific cells and othe need to see them. this is for DB that
some of the data in specific rows are restricted for some other users and the
other information in the row is not restricted, also the information in other
rows is not restricted in all the row. how can you help me with this.
 
M

michael

Compile error:

member already exist in an object module from wich this object module derives
 
G

Gord Dibben

Michael

Be aware that sheet and workbook passwords are easily cracked.

If you don't want certain users to see information, do not include that
information in your workbook.


Gord Dibben Excel MVP
 
M

michael

i know that the password are esaly cracked however the users that use this
worksheet are not that sofisticated and i also will protect the VBA Project
in a diffrent password so they will not be able to see the password. but i
need this information on one spreadsheet and i want to find a way to give for
some users the ability to see all the information and other users not to see
all the information (i.e. Salary and benefits)
 
P

Peter Rooney

Michael,

I'm stumped. Your error message has exceeded the tiny boundaries of my
technical knowledge. Sorry :)

However, here's something else. Put this line of code in your Worksheet_Open
macro to prevent users going to your VBA code via Alt+F11 and finding your
passwords.

Application.OnKey "%{F11}", ""

make sure that before you close the workbook, you include the line

Application.OnKey "%{F11}"

to reset the function of Alt+F11

If you add the following line to the beginning of a code module

Option Private Module

This will prevent any macro names contained in that code sheet being
displayed when you do Alt+F8 (run macro)

You can also disable/enable Alt+F8 in a similar way to the Alt+F11 example
above.

Hope this is of some use

Pete
 
D

Dave Peterson

If I were putting salaries and benefits in an excel workbook, I surely wouldnt
share it with others. All it takes is one curious person to make that
information available to lots of people.

But I'm just repeating Gord's warning...
 
D

David

I tried using your code. The box came up, I entered my password (wages) and
nothing happened. What did I do wrong? Here is the code I used:

Public Sub Password()

Message = "Enter Password"
Title = "Restricted User Mode"
DefaultPassword = "******"
ReturnedPassword = UCase(InputBox(Message, Title, DefaultPassword))

If ReturnedPassword <> "wages" Then
Exit Sub
Else
Call ChangeWageFlagForm
End If

End Sub
 
D

Dave Peterson

What does ChangeWageFlagForm do?

And just to double check, you may want to add a message if the password is
incorrect.

If ReturnedPassword <> "wages" Then
MsgBox "Wrong Password!"
Exit Sub
Else
Call ChangeWageFlagForm
End If
 
Top