betotototo
New Member
- Joined
- Jul 27, 2011
- Messages
- 4
Hi all,
I'm trying to figure out a vba code that will delete all sheets after a specific sheet NAME. I've found ones that will delete after a specific count (30 in this case):
But for my workbook, I want to delete everything after the sheet "TOI." There could be an infinite amount of sheets before "TOI." Can anyone help me reference that specific sheet and delete everything after it?
Thanks in advance.
PS: Brand spanking new to vba.
I'm trying to figure out a vba code that will delete all sheets after a specific sheet NAME. I've found ones that will delete after a specific count (30 in this case):
Code:
Sub DeleteSheets()
Dim lngLoop As Long
If ThisWorkbook.Worksheets.Count > 30 Then
Application.DisplayAlerts = False
For lngLoop = ThisWorkbook.Worksheets.Count To 31 Step -1
ThisWorkbook.Worksheets(lngLoop).Delete
Next lngLoop
Application.DisplayAlerts = True
End If
End Sub
But for my workbook, I want to delete everything after the sheet "TOI." There could be an infinite amount of sheets before "TOI." Can anyone help me reference that specific sheet and delete everything after it?
Thanks in advance.
PS: Brand spanking new to vba.