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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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