Why isn't my if not open working

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a spreadsheet that checks if a file is open and the command works fine. I copied the command from the working spreadsheet to another spreadsheet and now I get the error sub or function not defined. isFileOpen is highlighted. Can someone help me see what I have missed please?

VBA Code:
Sub LateCancel()

        Dim ws As Worksheet, sh As Worksheet, sht As Worksheet, wb As Workbook, WbPath As String, QTPath As String
        Set sh = Sheets("Totals")
        'Set sht = Sheets("Cancellations")
        Dim LCReq As String: LCReq = sh.[B32].Value
        Dim LCDt As String: LCDt = sh.[B34].Value
        WbPath = ThisWorkbook.Path
        QTPath = Left(WbPath, InStrRev(WbPath, "\") - 2)

Application.ScreenUpdating = False
       
        If Not isFileOpen("CSS_quoting_tool_29.5.xlsm") Then Workbooks.Open _
            QTPath & "\" & "CSS_quoting_tool_29.5.xlsm"
   
        For Each ws In Worksheets
                If ws.Name <> "Cancellations" And ws.Name <> "Totals" Then
                        With ws.[A3].CurrentRegion
                                .AutoFilter 1, LCDt
                                .AutoFilter 3, LCReq
                                .Offset(1).EntireRow.Copy sh.Range("A" & Rows.Count).End(xlUp).Offset(1)
                                .Offset(1).EntireRow.Delete
                                .AutoFilter
                        End With
                End If
        Next ws
       
sh.Range("B32,B34").ClearContents
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Is this code in another WORKBOOK ?
If so, did you copy the IsFileOpen function as well ??
 
Upvote 0
Did you paste the function in a Standard Module ??
 
Upvote 0
I just remembered that I forgot to paste the IsFileOpen function into that workbook. I did so and now I am not getting that error.

Thanks Michael.
 
Upvote 0
I did ask that question !!... (y) :cool::cool:
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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