通过使用命令按钮,可以通过检查工作簿中是否存在特定工作表名称来关闭用户窗体
Private Sub Close1_Click()
' Protect and Hide
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
If InStr(1, ws.Name, "FSS-TEM-00025") Then
(ws.Name, "FSS-TEM-00025" ).Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveWindow.SelectedSheets.Visible = False
Unload Me
Else
Unload Me
End If
Next
'Unload Me
End Sub