Run-time error '91' Help

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. 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

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
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top