Code Error Run Time erro 13

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
Type Mismatch

I'm getting the error on "If Not Evaluate...."

Code:
Sub Get_CMOP()
 Application.ScreenUpdating = False
    
    'Dim Consolidate As Workbook
    Dim SWEEP As Workbook
    'Dim CMOP As Workbook
    Dim CMOP As Workbook
    'Dim xLRw As Long
    'Dim xCMOPK As Long

    
    Set SWEEP = ThisWorkbook

    CMOPK = Application.GetOpenFilename("Excel files (*.xls*), *.xls*")

    
    If CMOPK <> False Then
        Workbooks.Open (CMOPK)
        Set CMOP = ActiveWorkbook
        
            If Not Evaluate("isref(2017 CMOPK!a1)") Then
                MsgBox "The Selected Workbook does not contain a 54_TPL_01_02 tab"
                CMOP.Close False
                Exit Sub
            Else
                ActiveWorkbook.Sheets("2017 CMOPK").Copy SWEEP.Sheets(SWEEP.Sheets.Count)
        
                CMOP.Close False
            End If
            
    Else

    End If
        
    Application.ScreenUpdating = True


End Sub

I want to send up a message box, close a workbook and end the sub if a certain tab is not there.

THNAKS AGAIN!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You could try
Code:
If CMOPK <> False Then
    Workbooks.Open (CMOPK)
    Set CMOP = ActiveWorkbook
    On Error Goto Halt
    ActiveWorkbook.Sheets("2017 CMOPK").Copy SWEEP.Sheets(SWEEP.Sheets.Count)
        


Halt:
CMOP.Close False
On Error Goto 0

End Sub
 
Upvote 0
If the sheet name contains spaces you have to wrap it in single quotes ' like
Code:
isref('2017 CMOPK'!a1)
 
Last edited:
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,992
Messages
6,122,631
Members
449,095
Latest member
bsb1122

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