Balrajss0121
New Member
- Joined
- May 6, 2020
- Messages
- 11
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi, I have a macro that enables me to move to the previous sheet. However when back at the start I would want it to loop back to the last sheet in the workbook. The current code is displayed below and it checks for any hidden sheets and it misses out the first sheet which is the home sheet. Any help would be appreciated in solving this
Sub PreviousSheet()
Dim i As Integer
i = ActiveSheet.Index - 1
If i > Sheets.Count Then i = 2
Sheets(i).Activate
End Sub

Sub PreviousSheet()
Dim i As Integer
i = ActiveSheet.Index - 1
If i > Sheets.Count Then i = 2
Sheets(i).Activate
End Sub