Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide colum using VBA password
Does anyone know a VBA code to hide a coumn using a password?
|
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide colum using VBA password
At is simplest, you could use something like the following to hide/unhide
column "E". Sub HideUnhideWithPassword() Dim PW As String PW = InputBox("Enter a password:") If StrComp(PW, "CorrectPassword", vbBinaryCompare) = 0 Then With ThisWorkbook.Worksheets("Sheet1").Columns("E") .Hidden = Not .Hidden End With Else MsgBox "Invalid Password" End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "shapiro" wrote in message ... Does anyone know a VBA code to hide a coumn using a password? |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide colum using VBA password
Hello Chip,
Thank you for response, I tried but I think i am doing something wrong. First I hid column E then I went to VBA and inserted the code. When I ran the module it asked me to "enter a password" I typed "correctpassword" but when I tried to unhide the column, the colums that was hidden appeared. Should it have asked me for a password? "Chip Pearson" wrote: At is simplest, you could use something like the following to hide/unhide column "E". Sub HideUnhideWithPassword() Dim PW As String PW = InputBox("Enter a password:") If StrComp(PW, "CorrectPassword", vbBinaryCompare) = 0 Then With ThisWorkbook.Worksheets("Sheet1").Columns("E") .Hidden = Not .Hidden End With Else MsgBox "Invalid Password" End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "shapiro" wrote in message ... Does anyone know a VBA code to hide a coumn using a password? |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide colum using VBA password
The code I wrote prompts for a password and if the correct password is
entered, it hides column E if it is visible, or unhides column E if it is hidden. If you don't want to unhide the column, change ..Hidden = Not .Hidden ' to ..Hidden = True The code doesn't prevent the user from manually hiding or unhiding the column. To do that, you'll need to protect the sheet with a password and use that password in the code: Sub HideUnhideWithPassword() Dim PW As String PW = InputBox("Enter a password:") If StrComp(PW, "CorrectPassword", vbBinaryCompare) = 0 Then ActiveSheet.Unprotect Password:=PW With ThisWorkbook.Worksheets("Sheet1").Columns("E") .Hidden = True End With ActiveSheet.Protect Password:=PW Else MsgBox "Invalid Password" End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "shapiro" wrote in message ... Hello Chip, Thank you for response, I tried but I think i am doing something wrong. First I hid column E then I went to VBA and inserted the code. When I ran the module it asked me to "enter a password" I typed "correctpassword" but when I tried to unhide the column, the colums that was hidden appeared. Should it have asked me for a password? "Chip Pearson" wrote: At is simplest, you could use something like the following to hide/unhide column "E". Sub HideUnhideWithPassword() Dim PW As String PW = InputBox("Enter a password:") If StrComp(PW, "CorrectPassword", vbBinaryCompare) = 0 Then With ThisWorkbook.Worksheets("Sheet1").Columns("E") .Hidden = Not .Hidden End With Else MsgBox "Invalid Password" End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "shapiro" wrote in message ... Does anyone know a VBA code to hide a coumn using a password? |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Hide colum using VBA password
Thanks Chip. It worked perfectly!!
"Chip Pearson" wrote: The code I wrote prompts for a password and if the correct password is entered, it hides column E if it is visible, or unhides column E if it is hidden. If you don't want to unhide the column, change ..Hidden = Not .Hidden ' to ..Hidden = True The code doesn't prevent the user from manually hiding or unhiding the column. To do that, you'll need to protect the sheet with a password and use that password in the code: Sub HideUnhideWithPassword() Dim PW As String PW = InputBox("Enter a password:") If StrComp(PW, "CorrectPassword", vbBinaryCompare) = 0 Then ActiveSheet.Unprotect Password:=PW With ThisWorkbook.Worksheets("Sheet1").Columns("E") .Hidden = True End With ActiveSheet.Protect Password:=PW Else MsgBox "Invalid Password" End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "shapiro" wrote in message ... Hello Chip, Thank you for response, I tried but I think i am doing something wrong. First I hid column E then I went to VBA and inserted the code. When I ran the module it asked me to "enter a password" I typed "correctpassword" but when I tried to unhide the column, the colums that was hidden appeared. Should it have asked me for a password? "Chip Pearson" wrote: At is simplest, you could use something like the following to hide/unhide column "E". Sub HideUnhideWithPassword() Dim PW As String PW = InputBox("Enter a password:") If StrComp(PW, "CorrectPassword", vbBinaryCompare) = 0 Then With ThisWorkbook.Worksheets("Sheet1").Columns("E") .Hidden = Not .Hidden End With Else MsgBox "Invalid Password" End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "shapiro" wrote in message ... Does anyone know a VBA code to hide a coumn using a password? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hide a column using a password | Excel Discussion (Misc queries) | |||
hide column with password | Excel Discussion (Misc queries) | |||
how to hide raws and use password | Excel Worksheet Functions | |||
how to hide raws and use password | Excel Discussion (Misc queries) | |||
How do I hide a worksheet in Excel and use a password to un-hide . | Excel Discussion (Misc queries) |