Share via

Select Method of Worksheet Class failed Error

Anonymous
2012-06-05T16:36:21+00:00

Why am I getting the above error on the highlighted code line?

Sub copy_currentFile(currFilePath As Variant)

If (currFilePath Like "*Shipped Delivered*") Or (currFilePath Like "*BudgetTracker*") Or _

   (currFilePath Like "*Overton Report*") Then

    Workbooks.Open Filename:=currFilePath, ReadOnly:=True, UpdateLinks:=False

    With ActiveWorkbook

        If (currFilePath Like "*Shipped Delivered*") Then

            .Sheets(1).Select   <+++++++        ElseIf (currFilePath Like "*Budget Tracker*") Then

            .Sheets("BUDGET DETAIL").Select

        ElseIf (currFilePath Like "*Overton Report*") Then

            .Sheets("CASPR01 - Milestone Export").Select

        End If

        .ActiveSheet.Copy before:=ThisWorkbook.Sheets(1)

        Application.DisplayAlerts = False

        .Close

    End With

End If

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-06-05T17:10:02+00:00

You will get this error if the sheet is hidden or cannot be selected for some other reason.

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful