Professional Documents
Culture Documents
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for
Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Reverse the order of the worksheets
1
2
3
4
5
6
7
8
Sub ReverseSheets()
'Update 20140526
Dim xCount As Integer
xCount = Application.ActiveWorkbook.Worksheets.Count
For i = 1 To xCount - 1
Application.Worksheets(1).Move After:=Application.Worksheets(xCount - i + 1)
Next
End Sub
3. Then press F5 key to run this code, and the order of all worksheet tabs will be reversed
immediately.
Tip: Press the F5 key again, all worksheet will be ordered with the original order.
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub
OR
For Excel 2007 Version :
You can follow the following steps to avoide the privacy warning.
1 Menu Button "on the top left of the excel window"
2 Excel Option
3 Trust Center
4 Trust Center setting
5 Privacy Options
6 unmark the "Remove personal information from file properties on save"
OR
In the workbook module add the following and it will save like normal without
using special buttons.
Technically I didn't have to use the "With" and the "."s but this is better.......
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
With Application
.DisplayAlerts = False
.EnableEvents = False
ThisWorkbook.Save
Cancel = True
.EnableEvents = True
.DisplayAlerts = True
End With
End Sub
The previous code over rode the Save As box. Use this instead
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
With Application
.DisplayAlerts = False
.EnableEvents = False
If SaveAsUI Then
Application.Dialogs(xlDialogSaveAs).Show
Else
ThisWorkbook.Save
End If
Cancel = True
.EnableEvents = True
.DisplayAlerts = True
End With
End Sub