Reputation: 13
Been searching but cannot find any reference to what I am trying to accomplish.
Background
I use a worksheet (worksheer#2) to enter certain data for an aircraft model. When the data is correct I run a macro to copy that data into another worksheet and rename the cipued one with the aircraft name. I do this for as many aircraft as i need. All created sheets are all placed between two other blank sheets named Start and End.
I can manipulate any specific worksheet by name using buttons on worksheet #2 perfectly and when the macro runs it updates relevant cells on worksheet#2 accordingly.
Those values are required elsewhere in my workbook and have to be correct. That all works fine but it all falls over when the worksheet is deleted/moved by way of right clicking the worksheet tab and then deleteing or holding and dragging the sheet to another location.
Is there a way to capture the worksheet name when it is manipulated in this fashion so I can use the info to update data on worksheet #2 with?
Upvotes: 1
Views: 39
Reputation: 21639
There is a worksheet-level event called BeforeDelete
.
Right click on the tab and choose View Code
In the General
drop-down at the top-left of the VBA Editor, choose ``WorkSheet" and in the (Declarations)
drop down at top-right, choose BeforeDelete
.
This will create an empty procedure where you can add your code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Upvotes: 0