View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default 'very hidden' columns

First, if it's sensitive data, you should re-evaluate whether you should
be distributing it at all. Bypassing worksheet passwords is a matter of
a few seconds if you have the wherewithal to find these groups. See

http://www.mcgimpsey.com/excel/removepwords.html

Second, xlVeryHidden applies only to a worksheet's visibility, not to
columns.

Here's one way toggle hiding your columns:

Public Sub ToggleHiddenColumns()
Const sPWORD As String = "drowssap"
With ActiveSheet
.Unprotect sPWORD
With .Range("C:F,H:K").EntireColumn
.Hidden = Not .Hidden
End With
.Protect sPWORD
End With
End Sub

If you want the user to enter the password, here's one way:

Public Sub ToggleHiddenColumns()
Dim vPWord As Variant
With ActiveSheet
Do
vPWord = Application.InputBox( _
Prompt:="Enter Password:", _
Type:=2)
If vPWord = False Then Exit Sub 'User canceled
Loop Until Len(vPWord) 0
On Error GoTo Wrong_Password
.Unprotect vPWord
On Error GoTo 0
With .Range("C:F,H:K").EntireColumn
.Hidden = Not .Hidden
End With
.Protect vPWord
End With
Exit Sub
Wrong_Password:
MsgBox "That was the wrong password!"
End Sub





In article ,
gavmer wrote:

HI all

Im after a simple macro that will unprotect sheet1, hide columns c-f
and h-k and re-protect the sheet. Can an xlveryhidden function be used
as it is sensitive data being hidden?? Also, a click event to unhide
the columns would be needed.

Password protection (user prompt) would be needed also??

Any ideas??

Cheers to all!!!!