Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.