ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Method of Sheets (https://www.excelbanter.com/excel-programming/329779-select-method-sheets.html)

Brenda Meza via OfficeKB.com

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

Doug Glancy

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" wrote in message
...
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




Brenda Meza via OfficeKB.com[_2_]

Select Method of Sheets
 
Thank you very much i try it and it work propely

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


All times are GMT +1. The time now is 06:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com