MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Array of sheets

Posted by Bill Mahoney on January 24, 2002 8:08 AM

Hello, i have a workbook containing 30 or so sheets. I am trying to find a way in which i can enter all the sheets into an array so i can perform a loop to copy and paste certain info into certain cells. I know i can do this by adding all the sheet names in the code and assigning them to a position in the array. But i wasn't sure if each sheet couldn't be called by an index that already exists instead of the sheet name. Thanks for any help.

Bill Mahoney
The Alcott Group

Posted by Juan Pablo G. on January 24, 2002 8:53 AM

If you do

For i = 1 to Sheets.Count 'Or Worksheets.Count
Debug.Print Sheets(i).Name
Next i

Will give you the sheet's name according to their position in the workbook.

Juan Pablo G.

Posted by Bill Mahoney on January 24, 2002 9:03 AM

thanks for the help--it worked great.