ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stuck myself - can't bring back very hidden (https://www.excelbanter.com/excel-programming/272313-re-stuck-myself-cant-bring-back-very-hidden.html)

Tom Ogilvy

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







Ed[_9_]

Stuck myself - can't bring back very hidden
 
"Tom Ogilvy" wrote in message
...
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


Thanks, Tom. Maybe I ought to leave off learning programming for a while
and figure out how to proof-read!! *sigh*

Ed




All times are GMT +1. The time now is 07:43 AM.

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