PDA

View Full Version : Hide unhide sheets with navigation buttons



IggySoup
07-13-2023, 12:47 AM
Morning all hope you can help :)

I have a workbook which has 14 tabs a couple of which are hidden. I am trying to make an exercise for a training exercise and i want to hide the ribbon and staus bar etc (which i've sorted)

However, I would like for the the user to be able to navigate back and forth within the tabs using forward/back arrows and for only the selected tab to be visible.

I know the hide/unhide code but i was wondering if someone had something that would work like this for me 9and ignoring the hidden tab which is used to calculate scores from the data entered on the previous tabs

Can anyone please help me with this?

Thanks so much in adance

Iggy

Logit
07-19-2023, 03:27 PM
Option Explicit

Sub SelectNextSheet()
'PURPOSE: Select the next visible sheet in the spreadsheet
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault


Dim sht As Worksheet


'Store currently selected sheet
Set sht = ActiveSheet


'Loop to next sheet until visible one is found
On Error Resume Next

Do While sht.Next.Visible <> xlSheetVisible
If Err <> 0 Then Exit Do
Set sht = sht.Next
Loop

'Activate/Select next sheet
sht.Next.Activate

On Error GoTo 0


End Sub


Sub SelectPreviousSheet()
'PURPOSE: Select the next visible sheet in the spreadsheet
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault


Dim sht As Worksheet


'Store currently selected sheet
Set sht = ActiveSheet


'Loop to next sheet until visible one is found
On Error Resume Next

Do While sht.Previous.Visible <> xlSheetVisible
If Err <> 0 Then Exit Do
Set sht = sht.Previous
Loop

'Activate/Select next sheet
sht.Previous.Activate

On Error GoTo 0


End Sub