Hi,
I have this code that prompts a message if a user tries to add a new sheet in a workbook.
I have three sheets that is allowed to be in the workbook called "Information", "Prices", "Copied Prices" in that order.
If a user is working in sheet "Prices" and decides to try and add a new sheet, the message promts saying he is not allowed to do so, but he then ends up at "Copied Prices" sheet because that is the next sheet in line, but not necessarily the last sheet that he was using.
How do I make excel return to the last active sheet?
Please see the code below:
Private Sub Workbook_NewSheet(ByVal Sh As Object)
'Update 20140623
With Application
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sh.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End With
MsgBox "You are not allowed to add a new sheet"
End Sub
I have this code that prompts a message if a user tries to add a new sheet in a workbook.
I have three sheets that is allowed to be in the workbook called "Information", "Prices", "Copied Prices" in that order.
If a user is working in sheet "Prices" and decides to try and add a new sheet, the message promts saying he is not allowed to do so, but he then ends up at "Copied Prices" sheet because that is the next sheet in line, but not necessarily the last sheet that he was using.
How do I make excel return to the last active sheet?
Please see the code below:
Private Sub Workbook_NewSheet(ByVal Sh As Object)
'Update 20140623
With Application
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sh.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End With
MsgBox "You are not allowed to add a new sheet"
End Sub
Last edited: