Below Example will sort the worksheets in alphbetical order and then move them accordingly.
VBA Macro Code / Syntax :
Mysheets= Sheets.Count
For i = 1 To Mysheets- 1
For j = i + 1 To Mysheets
If Sheets(j).Name < Sheets(i).Name Then
Sheets(j).Move before:=Sheets(i) ' Swap the sheets
End If
Next j
Next i
Above code will sort the worksheets in Workbook using Excel Macro in 2007/2010/2003.
VBA Macro Code / Syntax :
Mysheets= Sheets.Count
For i = 1 To Mysheets- 1
For j = i + 1 To Mysheets
If Sheets(j).Name < Sheets(i).Name Then
Sheets(j).Move before:=Sheets(i) ' Swap the sheets
End If
Next j
Next i
Above code will sort the worksheets in Workbook using Excel Macro in 2007/2010/2003.
No comments:
Post a Comment