Hi
I have a worksheet_change event that I want to put in place but I am having problems ensuring that this event exits if columns A to E are accidentally deleted.
I had the same problem with my code if a row was inserted but I started the event with the following:
Public Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = ActiveSheet.Columns.Count Then Exit Sub
This works fine. However, I am not sure how I can trap the possibility of someone accidentally deleting columns A to E as this will trigger hundreds of message boxes confirming an error that I set up for every cell change. Obviously I do not want this to happen so would like an easy way to either prompt the user to confirm if they want to delete the entire column or allow it and exit the worksheet_change event.
Any help much appreciated.
Thanks
I have a worksheet_change event that I want to put in place but I am having problems ensuring that this event exits if columns A to E are accidentally deleted.
I had the same problem with my code if a row was inserted but I started the event with the following:
Public Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = ActiveSheet.Columns.Count Then Exit Sub
This works fine. However, I am not sure how I can trap the possibility of someone accidentally deleting columns A to E as this will trigger hundreds of message boxes confirming an error that I set up for every cell change. Obviously I do not want this to happen so would like an easy way to either prompt the user to confirm if they want to delete the entire column or allow it and exit the worksheet_change event.
Any help much appreciated.
Thanks