2

I'd like to reverse the order of the sheets in an Excel 2007 workbook and wonder if there is any way to do this other than a manual tedious process. I have around 100 sheets, so I'd like to avoid the manual way of doing this, but I see no programmatic way to accomplish this.

Similarly, is there an easy way to search for a sheet by its name to select it?

2 Answers 2

2

You can loop through the sheets programmatically and reverse their order using code similar to the following:

Sub ReverseSheets()
Dim i As Integer

For i = 1 To Worksheets().count
    Worksheets(i).Move before:=Worksheets(1)
Next i

End Sub

This code will automatically reverse all sheets in a workbook. The exact number of sheets is irrelevant because it checks for the number of sheets each time.

As for searching for sheet names, it is possible but significantly more complicated than reversing the sheets. Here are a couple of sites to get you started:

http://automation-beyond.com/2010/01/27/how-to-find-excel-worksheet-by-name/

http://www.mrexcel.com/forum/excel-questions/58374-visual-basic-applications-find-sheet-name.html

0

To change a sheet name, you can use VBA:

  1. Select your sheet: Sheets("Sheet1".Select

  2. Rename your sheet: Sheets("Sheet1").Name = "SheetA"

Then just create a loop to cycle through all of your sheets and have it assign the names you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .