Forum Discussion

Ana McCorkhill's avatar
Ana McCorkhill
Copper Contributor
Aug 16, 2018
Solved

Macro Using a Relative Function for all Sheets

I want to create a macro that goes to the next sheet, but I can only create a macro that goes to a specific sheet, regardless of whether or not I'm selecting the "Use Relative References" button when...
  • Ana McCorkhill's avatar
    Ana McCorkhill
    Aug 16, 2018
    Thank you!
    Had to tweak the macro a little bit to get the code to work exactly as I was wanting:

    Sub NextSheet()
    '
    ' NextSheet Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+L
    '
    nextSheetIndexNumber = ActiveSheet.Index + 1

    If nextSheetIndexNumber > Sheets.Count Then
    Sheets(1).Activate
    Else
    Sheets(nextSheetIndexNumber).Activate
    End If

    End Sub

Resources