View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
yogendra joshi yogendra joshi is offline
external usenet poster
 
Posts: 48
Default macro to re-order sheets based on cell value?

This Should help you


Sub arrange()
Dim ws As Worksheet
Dim cnt, cnt1
Application.ScreenUpdating = False

For cnt = 1 To Sheets.Count - 1
For cnt1 = cnt + 1 To Sheets.Count
'Change A1 your cell or cell name
If Sheets(cnt).Range("A1").Value Sheets(cnt1).Range("A1").Value Then
Sheets(cnt).Move After:=Sheets(cnt1)
End If
Next
Next

Application.ScreenUpdating = False
End Sub


neowok < wrote:

I have 22 sheets with dientical layouts in a workbook. what i need is a
macro fo some kind that will re-order the sheets in the workbook based
on the value in a particular cell (it will be the same cell in each of
the sheets).

Basicallly I have 3 sets of dates on these sheets and i need to be able
to order the sheets in the workbook based on which one of these dates
I need to sort by at the time (basically putting the earliest dates at
the front).

A macro that will sort the 22 sheets putting the earliest date in C1 at
the start would do. If i then need to order them by E1 instead then
I'll only have to change a tiny bit in the macro.

Thanks


---
Message posted from http://www.ExcelForum.com/