View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Stuck myself - can't bring back very hidden

It doesn't work because the only thing the msgbox can return is vbOK and he
is checking for vbYes

MsgBox("Click to View Data", vbOKOnly) = vbYes

But if the user can only return vbOK, then why even bother to check

MsgBox "Click to View Data", vbOKOnly

Sheets("Sheet1").Visible = True

Sheets("Sheet1").Activate

Sheets("Sheet3").Visible = False


Would function the same.

Regards,
Tom Ogilvy




"Tim" wrote in message
...
Ed,

Try replacing the code that starts with, "If MsgBox" with this:

Dim Ans As Integer
Ans = MsgBox("Click to View Data", vbOKOnly)
If Ans = 1 Then
Sheets("Sheet1").Visible = True
Sheets("Sheet1").Activate
Sheets("Sheet3").Visible = False
End If

I don't know why your code doesn't work (it wouldn't for me either).
Someone brighter than I can probably answer off the top of their head.

Tim

"Ed" wrote in message
...
I have the following code:



Private Sub Workbook_Open()

If ActiveWorkbook.ReadOnly = False Then

ThisWorkbook.Saved = True

ThisWorkbook.ChangeFileAccess xlReadOnly

End If



Worksheets("Sheet1").Visible = xlVeryHidden

Worksheets("TIRs").Visible = xlVeryHidden



If MsgBox("Click to View Data", vbOKOnly) = vbYes Then

Sheets("Sheet1").Visible = True

Sheets("Sheet1").Activate

Sheets("Sheet3").Visible = False

End If



End Sub



The message box pops up, but nothing happens when I click the Yes button

on
the message box.



What did I do wrong?



Ed