Macro for reordering tabs based on cells.

kyleboyd

New Member
Joined
Feb 22, 2011
Messages
15
Can someone help me with a macro for reordering tabs based on cell values. I have a workbook with about 40 sheets, each sheet name (a project name) corresponds to a cell in a list on a master sheet which is then sorted based on a different value (a date). So I would like the sheets to be ordered in the same order as on the master sheet. Thanks for the help!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Here's what I came up with:

Code:
Sub OrderSheets()
    Dim i As Integer
    For i = 1 To Selection.CurrentRegion.Rows.Count - 1
       Dim sheetTitle As String
       sheetTitle = ActiveCell.Value
       Dim sheetPrevious As String
       sheetPrevious = ActiveCell.Offset(-1, 0).Value

       Sheets(sheetTitle).Move After:=Sheets(sheetPrevious)
       Sheets("Project Master").Select
       ActiveCell.Offset(1, 0).Select
       Next i
End Sub

It works, I may have to do some fine tuning. (Guess I just needed to put some thought into it)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,713
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top