+ Reply to Thread
Results 1 to 3 of 3

Select Method of Sheets

  1. #1
    Brenda Meza via OfficeKB.com
    Guest

    Select Method of Sheets

    I have a macro and I get the next error: "run-time error 1004 select method
    of sheets class failed" I'm trying to do un array of sheets and then select
    copy and cut some row’s here is part of my code:

    z = Sheets("NovaUSA").Index 'to get the index for the first row to start
    y = Sheets("Beans (P)").Index
    ReDim SheetsGroup(z To y)
    For i = z To y
    SheetsGroup(i) = Sheets(i).Name
    Next i

    Sheets(SheetsGroup).Select ' here its where I get the error
    Columns("AG:AK").Select
    Range("AG6").Activate
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft

    Could somebody help me

  2. #2
    Doug Glancy
    Guest

    Re: Select Method of Sheets

    Brenda,

    I think you need a corresponding array index along with a for/next loop
    around your deletion code:

    For i = z To y
    Sheets(SheetsGroup(i)).Select ' here its where I get the error
    Columns("AG:AK").Select
    Range("AG6").Activate
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    next i

    hth,

    Doug

    "Brenda Meza via OfficeKB.com" <forum@nospam.OfficeKB.com> wrote in message
    news:79fb82b3d345433ca7d70b73bcb2034e@OfficeKB.com...
    > I have a macro and I get the next error: "run-time error 1004 select

    method
    > of sheets class failed" I'm trying to do un array of sheets and then

    select
    > copy and cut some row's here is part of my code:
    >
    > z = Sheets("NovaUSA").Index 'to get the index for the first row to start
    > y = Sheets("Beans (P)").Index
    > ReDim SheetsGroup(z To y)
    > For i = z To y
    > SheetsGroup(i) = Sheets(i).Name
    > Next i
    >
    > Sheets(SheetsGroup).Select ' here its where I get the error
    > Columns("AG:AK").Select
    > Range("AG6").Activate
    > Application.CutCopyMode = False
    > Selection.Delete Shift:=xlToLeft
    >
    > Could somebody help me




  3. #3
    Brenda Meza via OfficeKB.com
    Guest

    Re: Select Method of Sheets

    Thank you very much i try it and it work propely

    --
    Message posted via http://www.officekb.com

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1