A worksheet can not be closed, merely deactivated or hidden.
Try setting the visible property of all but the required sheet to
xlVeryHidden:
Sub Tester()
Dim sh As Object
For Each sh In ActiveWorkbook.Sheets
If sh.Name <> "Permitted Sheet's name" Then
sh.Visible = xlVeryHidden
End If
Next
End Sub
If this approach is not acceptable you could paste something like the
following into the worksheet module:
Private Sub Worksheet_Deactivate()
MsgBox "Only sheet " & Me.Name & " is available", _
vbInformation
Me.Activate
End Sub
I guess I need to be more specific. I want to prevent the automatic action
that takes place when the user clicks on the "X" in the top right of the
worksheet (NOT the workbook - that's ok to use). I have created a macro that
closes the worksheet and does some other operations.
I don't know how I can be more explicit. I'm not referring to the TOP,
rightmost "X", which closes the applications. I have several worksheets in
my workbook app. When I need to display two of the worksheets at the same
time, each taking part of the app window, I need to prevent the user from
clicking the worksheet "x" when that sheet is active.
I cannot seem to trap that event.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.