Hi there
I'm using a message box to unhide some sheets in my workbook and want to be able to cancel the command when I have unhidden the ones I want. I'm using the code below and though it seemed to work a few times, it won't do so now. Can anyone tell me how I can correct it?
Thanks in advance for any help.
datafiend
![]()
Sub UnhideSomeSheets() Dim sSheetName As String Dim sMessage As String Dim Msgres As VbMsgBoxResult Dim wsSheet As Worksheet For Each wsSheet In ActiveWorkbook.Worksheets If wsSheet.Visible = xlSheetHidden Then sSheetName = wsSheet.Name sMessage = "Unhide the following sheet?" _ & vbNewLine & sSheetName Msgres = MsgBox(sMessage, vbYesNoCancel) If Msgres = vbYes Then wsSheet.Visible = xlSheetVisible ElseIf Msgres = vbCancel Then Exit Sub End If Next wsSheet End Sub
Bookmarks