Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8447133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:06:39+00:00 2026-06-10T10:06:39+00:00

I need to pull a sheet’s position in a workbook knowing only it’s name

  • 0

I need to pull a sheet’s position in a workbook knowing only it’s name — so for instance:

if we have a sheet, say
Workbook.Sheets("Sheet2")

how would I find the corresponding integer so that I could refer to it as:
say i is an integer
Workbook.Sheets(i)

I need to be able to do this reverse indicing so I can refer to sheets next to the sheet I’m referencing.

Thank you for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:06:40+00:00Added an answer on June 10, 2026 at 10:06 am
    Workbook.Sheets("sheet name").Index
    

    Edit: brettdj’s answer inspired me, so I wrote this function which could probably be cleaned up infact thinking about it, if I were actually going to use and support this I would probably make a find sheet function instead of what the sub does if you say true for the 4th parameter:

    Function adjacentsheet(Optional ws As Worksheet, Optional wsName As String, Optional nextSheet As Boolean = True, Optional search As Boolean = False) As Worksheet
    'Expects worksheet or worksheet.name if blank, uses activesheet.
    'Third parameter indicates if the next sheet or previous sheet is wanted, default is next = true
    'Indicates adjacent sheet based on worksheet provided.
    'If worksheet is not provided, uses worksheet.name.
    'If no worksheet matches corresponding name, checks other workbooks if 4th parameter is true
    'If no worksheet can be found, alerts the user.
    'Returns found worksheet based upon criteria.
    
    
    If (ws Is Nothing) Then
        If wsName = "" Then
            Set adjacentsheet = adjacentsheet(ActiveSheet, , nextSheet)
        Else
            'Check all workbooks for the wsName, starting with activeWorkbook
            On Error Resume Next
            Set ws = Sheets(wsName)
            On Error GoTo 0
            If (ws Is Nothing) Then
                If search = True Then
                    If Workbooks.Count = 1 Then
                        GoTo notFound
                    Else
                        Dim wb As Workbook
                        For Each wb In Application.Workbooks
                            On Error Resume Next
                            Set ws = wb.Sheets(wsName)
                            On Error GoTo 0
                            If Not (ws Is Nothing) Then
                                Set adjacentsheet = adjacentsheet(ws, , nextSheet)
                                Exit For
                            End If
                        Next
                        If (ws Is Nothing) Then GoTo notFound
                    End If
                Else
                    GoTo notFound
                End If
            Else
                Set adjacentsheet = adjacentsheet(ws, , nextSheet, search)
            End If
        End If
    Else
        With ws.Parent
            If nextSheet Then
                If ws.Index = .Sheets.Count Then
                    Set adjacentsheet = .Sheets(1)
                Else
                    Set adjacentsheet = .Sheets(ws.Index + 1)
                End If
            Else
                If ws.Index = 1 Then
                    Set adjacentsheet = .Sheets(.Sheets.Count)
                Else
                    Set adjacentsheet = .Sheets(ws.Index - 1)
                End If
            End If
        End With
    End If
    Exit Function
    notFound:
    MsgBox "Worksheet name could not be found!", vbCritical, "Invalid worksheet name."
    
    End Function
    

    Here are some usage examples:
    ‘Usage Examples

    Dim nextws As Worksheet
    'returns sheet before the active sheet
    Set nextws = adjacentsheet(, , False)
    'returns sheet after the active sehet
    Set nextws = adjacentsheet()
    'returns sheet after sheet named "Test" in current workbook
    Set nextws = adjacentsheet(, "Test")
    'returns sheet after sheet named "Test" in any open workbook checking current workbook first
    Set nextws = adjacentsheet(, "Test", , True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to pull out the Employees who have a pager. <Employees> <Employee> <Name>Michael</Name> <Phone
I have been given some poorly formatted data and need to pull numbers out
I have two different tables from which I need to pull data blogs which
I have a text source with nulls in it and I need to pull
I have been given a large quantity of Xml's where I need to pull
I need to pull the width of images, which I can only do after
I have a scenario where I need to pull the title from a img
I have a project where I need to pull in a lot of records
I have a chunk of HTML I need to pull a word from. The
I have a script where i need to pull two seperate and different RSS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.