ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unhide Columns With A Password (https://www.excelbanter.com/excel-programming/440184-unhide-columns-password.html)

Jim[_78_]

Unhide Columns With A Password
 
I am trying to create a small marco that unhides a few columns in excel, but
prompts for a password. Is this possible?

Thanks


Gord Dibben

Unhide Columns With A Password
 
It is possible with an inputbox.

Sub unhide()
pword = InputBox("enter the password")
If pword < "mypass" Then
MsgBox "incorrect password"
Exit Sub
Else
ActiveSheet.Range("A:A,C:C,D:D").EntireColumn.Hidd en = False
End If
End Sub

BUT...........without protecting the sheet, placing a password on a macro
would prove to be sort of useless.

Users could unhide the columns without using your macro.

Protect the sheet with columns hidden and a password to unprotect.

Users will have to know the password.

Also be warned that Excel's internal passwords are eaty to crack.


Gord Dibben MS Excel MVP

On Wed, 3 Mar 2010 15:44:34 -0000, "Jim" wrote:

I am trying to create a small marco that unhides a few columns in excel, but
prompts for a password. Is this possible?

Thanks



Jim[_78_]

Unhide Columns With A Password
 
Thanks for the reply. I think I have come up with a solution by using a
macro to unhide, but prompting to unlock the sheet with a password.

So, to hide the given cells, user hits a button with a macro, this hides the
relevant columns and locks the sheet. I does allow the user to format cells
etc.

Then the second button executes second macro, and this then prompts a
password to unprotect the sheet and then unhides. Now I just need to hide
the code from any sneaky users!

Macro 1

Columns("L:O").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select

ActiveSheet.EnableOutlining = True
ActiveSheet.Protect Password:="password", _
DrawingObjects:=True, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=False, _
AllowFormattingRows:=True, AllowInsertingColumns:=True,
AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True,
_
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True

Macro 2

ActiveSheet.Unprotect
Columns("K:P").Select
Selection.EntireColumn.Hidden = False
Range("A1").Select

"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
It is possible with an inputbox.

Sub unhide()
pword = InputBox("enter the password")
If pword < "mypass" Then
MsgBox "incorrect password"
Exit Sub
Else
ActiveSheet.Range("A:A,C:C,D:D").EntireColumn.Hidd en = False
End If
End Sub

BUT...........without protecting the sheet, placing a password on a macro
would prove to be sort of useless.

Users could unhide the columns without using your macro.

Protect the sheet with columns hidden and a password to unprotect.

Users will have to know the password.

Also be warned that Excel's internal passwords are eaty to crack.


Gord Dibben MS Excel MVP

On Wed, 3 Mar 2010 15:44:34 -0000, "Jim" wrote:

I am trying to create a small marco that unhides a few columns in excel,
but
prompts for a password. Is this possible?

Thanks



Gord Dibben

Unhide Columns With A Password
 
Alt + F11 to go to VBE

Select your workbook/project.

Right-clickVBAProject PropertiesProtectionLock for viewing.

Enter a password twice and don't forget it.

Save and close workbook.


Gord

On Thu, 4 Mar 2010 09:49:23 -0000, "Jim" wrote:

Then the second button executes second macro, and this then prompts a
password to unprotect the sheet and then unhides. Now I just need to hide
the code from any sneaky users!



Jim[_78_]

Unhide Columns With A Password
 
Thanks Gord

"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Alt + F11 to go to VBE

Select your workbook/project.

Right-clickVBAProject PropertiesProtectionLock for viewing.

Enter a password twice and don't forget it.

Save and close workbook.


Gord

On Thu, 4 Mar 2010 09:49:23 -0000, "Jim" wrote:

Then the second button executes second macro, and this then prompts a
password to unprotect the sheet and then unhides. Now I just need to hide
the code from any sneaky users!




All times are GMT +1. The time now is 01:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com