View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default Unhide Worksheet with Login UserForm


"RyanH" skrev i en meddelelse
...
Ooops!! Sorry this is what I have. Ignore my last post. Error is Method
'Visible' of object 'Sheets'

Private Sub cmbLogin_Click()

Select Case cboUserName
Case "Peter Maida"
If tbxPassword = "peterm2" Then

With Workbooks("CALCULATOR 11-5-2007.xls")
.Unprotect ("AdTech")
.Worksheets.Visible = False <==ERROR
.Sheets("QUOTE").Visible = True
.Protect ("AdTech")
End With

With Sheets("QUOTE")
.Unprotect Password:="AdTech"
.Range("F3").Value = "Peter Maida Ext. 208"
.Range("F4").Value = "E-mail: "
.Protect Password:="AdTech"
End With

Unload Me
Exit Sub
Else
MsgBox "YOUR MEMORY IS IMPRESSIVE! That's NOT the right
password. Try agian.", vbCritical
With tbxPassword
.Value = ""
.SetFocus
End With
End If
End Select

End Sub

"RyanH" wrote:

Hi Ryan

You have to refer to at worksheet name or a worksheet index number, ie
Worksheets(1).visible =....

If you are trying to hide all sheets but "Quote" try this:


With Workbooks("CALCULATOR 11-5-2007.xls")
.Unprotect ("AdTech")
For sh = 1 To .Sheets.Count
If .Sheets(sh).Name = "QUOTE" Then
.Sheets(sh).Visible = True
Else
.Sheets(sh).Visible = False
End If
Next
.Protect ("AdTech")
End With

Regards,

Per