Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hi guys, working on a code that will look into a newly opened workbook for either sheets ("R&O", "Executive Summary") if either or the sheets exists, delete them.
I came up with the below but do not know how to modify for multiple sheets and in the event one of the tabs don't exists look for the other.
Any help is appreciated!
I came up with the below but do not know how to modify for multiple sheets and in the event one of the tabs don't exists look for the other.
Any help is appreciated!
Code:
Sub find ()
Dim ws as worksheet
Dim Destbook as workbook
Set DestBook = Workbooks.Open(vFilename) 'vfilename is defined on my full code
For Each ws In DestBook.Worksheets 'Searches to ensure Sheets aren't already in workbook
If ws.Name = "R&O" Then
Sheets("R&O").Delete
End
End If
Next
End Sub