View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
* Kenneth *
 
Posts: n/a
Default Can't get Cancel to work in message box

I having problems with getting the cancel to cancel or close the massage box
at any time the macro is running.

Help

-----------------------------------------------------------------------------------------------

Sub HideYesNo()

Dim iYesNo As Integer
Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
If Sheets(ws.Name).Visible Then
iYesNo = MsgBox("Hide Sheet " & ws.Name & _
" ?", vbQuestion + vbYesNoCancel, _
"Hide This Sheet")
If iYesNo = vbCancel Then
Cancel = True
If iYesNo = vbYes Then
Sheets(ws.Name).Visible = False
End If
End If
End If
Next ws

Set wb = Nothing
Set ws = Nothing

------------------------------------------------------------------------------------------------