Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

With Object is giving me an error

Status
Not open for further replies.

RooSXL

Technical User
Sep 22, 2004
22
US
I have been trying to find out what error is in this code, but no luck whatsoever. I keep getting

RUN_TIME Error '1004'
Select Method of Range Class Failed

Code:
Set book = Workbooks.Open("C\FileName.xls
   With book.Sheets(2).Range("F1")
        .AutoFilter
        .AutoFilter Field:=7, Criteria1:="411"
[b][y]  .CurrentRegion.Select[/b][/y]
        .Copy
    End With

When I try to debug, it highlight in yellow where the error is coming from.

Can anyone help me out...please

Thanks,
 
probably need to activate it 1st - probably isn't the active sheet at the time
Code:
With book.Sheets(2)
    .activate
        with .Range("F1")
             .AutoFilter Field:=7, Criteria1:="411"
             .CurrentRegion.Select
             .Copy
        End With
End With


Rgds, Geoff

"Having been erased. the document thjat you are seeking. Must now be retyped"

Please read FAQ222-2244 before you ask a question
 
Thanks xlbo

However it know returns an error 1004. Activate method of range class failed

What could be possible cause?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top