Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
All I am trying to do is see if there is a worksheet named (page 2) or a worksheet named (Exhibit "I"), if there is then call Sub deleteWS. However I am getting a Runtime error: 91 on the Bold Print and underlined ws.Name. Not sure what I coded incorrectly. By the way, I recorded a macro to get the deleteWS code. Thank You
deleteSub
Code:
Private Sub Workbook_Open()
Application.OnKey "{F6}", "OpenForm"
Dim sPath As String, sFile As String
Dim wb As Workbook
Dim ws As Worksheets
If [U][B]ws.Name[/B][/U] = Worksheets("Exhibit " & """I"" ") Or Worksheets("page 2") Then
Call deleteWS
Else
sPath = "H:\GRP\EVERYONE\FORMS\"
sFile = sPath & "F-103-04 Exh I-Solid Dose Usage Record-Rev001.xlsx"
Set wb = Workbooks.Open(sFile)
Call OpenSDUsageRecord
End If
deleteSub
Code:
Sub deleteWS()
' delete Usage Record
Sheets("page 2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Exhibit ""I"" ").Select
ActiveWindow.SelectedSheets.Delete
End Sub