PritishS
Board Regular
- Joined
- Dec 29, 2015
- Messages
- 119
- Office Version
- 2007
- Platform
- Windows
Dear Sir/Madam,
Have a nice day!
Problem: I needed to delete sheets in between two sheets.
What have I tried yet: After looking in Internet I have found a code in this forum which does the exactly same.
Link : https://www.mrexcel.com/forum/excel-questions/762960-delete-all-sheets-between-sheets-x-y.html
Code is:
This works perfectly. But after running this code I am getting a wired problem.
Problem:
Symptom 1: After deleting my sheets between "First_Sheet" and "Last_Sheet", when I clicked 'Save' or do 'Ctrl+S' (Normal saving workbook), my excel crashes every time.
Symptom 2: After running this code also found that on all shapes on my "Last_Sheet" (I am using these shapes as button to run macro. Each shapes assigned to a macro) got deactivated, means on which I am unable to click.
Try no 2: Now I have changed the code to see if 'Delete Sheet' somehow creating the problem. I wrote the simple sheet array code to delete 5 sheets in between"First_Sheet" and "Last_Sheet"
But unfortunately, same problem happened as I mentioned above.
My research: I have done some searching and found a link here
https://www.mrexcel.com/forum/excel...annot-save-workbook-excel-keeps-crashing.html
I also have 87 named range in this workbook. But I'm unable to understand the problem link between named range and delete sheets.
Please guide me on this. Thanks in advance.
Thanks & regards,
PritishS
Have a nice day!
Problem: I needed to delete sheets in between two sheets.
What have I tried yet: After looking in Internet I have found a code in this forum which does the exactly same.
Link : https://www.mrexcel.com/forum/excel-questions/762960-delete-all-sheets-between-sheets-x-y.html
Code is:
Code:
Sub DeleteSheetsBetweenFirstAndLastMarkerSheets()
Dim X As Long
Application.DisplayAlerts = False
For X = Sheets("Last_Sheet").Index - 1 To Sheets("First_Sheet").Index + 1 Step -1
Sheets(X).Delete
Next
Application.DisplayAlerts = True
End Sub
This works perfectly. But after running this code I am getting a wired problem.
Problem:
Symptom 1: After deleting my sheets between "First_Sheet" and "Last_Sheet", when I clicked 'Save' or do 'Ctrl+S' (Normal saving workbook), my excel crashes every time.
Symptom 2: After running this code also found that on all shapes on my "Last_Sheet" (I am using these shapes as button to run macro. Each shapes assigned to a macro) got deactivated, means on which I am unable to click.
Try no 2: Now I have changed the code to see if 'Delete Sheet' somehow creating the problem. I wrote the simple sheet array code to delete 5 sheets in between"First_Sheet" and "Last_Sheet"
Code:
Sub deleteSheets()
Application.DisplayAlerts = False
ActiveWorkbook.Unprotect Password:="123"
Sheets(Array("CAL1", "CAL2", "CAL3", "CAL4", "CAL5")).Delete
ActiveWorkbook.Protect Password:="123"
Application.DisplayAlerts = False
End Sub
But unfortunately, same problem happened as I mentioned above.
My research: I have done some searching and found a link here
https://www.mrexcel.com/forum/excel...annot-save-workbook-excel-keeps-crashing.html
I also have 87 named range in this workbook. But I'm unable to understand the problem link between named range and delete sheets.
Please guide me on this. Thanks in advance.
Thanks & regards,
PritishS
Last edited: