- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Get the Current Sheet Number of a Workbook?
Sometimes the user is working with multiple worksheets at the same time. While working with a large number of sheets, obtaining current sheet numbers is important to track the current working operations status. To access the worksheet number, for this tutorial, we are using two strategies, the first strategy involves setting the sheet number on the status bar, and the second strategy involves using the VBA code. VBA code is an effective way to write code once, and the same code can be used to process data any number of times, by simply calling the associated module.
A list of solutions that allow the user to evaluate the current sheet number is given below:
The first way is to display the sheet number in the status bar by enabling the option feature.
Another way is to use the excel visual basic analysis code.
Examples to Obtain the Current Workbook Sheet Number in Excel
Consider the below-given example to enable the status bar option:
To solve the required task, consider the below given workbook:
After that click on the “+” sign to add more sheets. Create 3 sheets, by clicking on “+” sign two or more times.
Sheets will appear at the bottom of the page:
Go to the status bar of the excel sheet and right click on the sheet. Consider the area depicted below:
Right click will display the below given option in front of user.
Choose the “sheet number” option.
This will display the sheet number on the bottom of the excel sheet.
This example will allow user to add the feature of current sheet number at the bottom of the excel sheet. After enabling the feature user can easily track the sheet number from the status bar.
Let’s consider another example to obtain the current sheet number. The below given example will demonstrate the user of VBA code to access the current sheet number.
Consider below given steps to understand the procedure:
To solve the task by using the VBA. Firstly, go to the “Developer” tab and click on “Visual Basic” under the “code” section.
This will display the below given Microsoft VBA area:
After that user need to write a module definition. This module contains code to perform the required task. To do so, click on “Insert” tab module. This will display code area to user.
In the appeared code editor, copy the below given code:
' define module header Sub Get_Sheet_number() ' use index instance to access sheet number MsgBox ActiveSheet.Index ' end of defined module End Sub
Snapshot of code area
After typing the code to the code area. Now, it is the time to execute the code. To do so, click on “run” option. This will execute the provided code:
The finally obtained results are given below:
This tutorial illustrates two simple strategies to obtain the current sheet number. First case involved the use status bar while the other option allow user to use the VBA code. Both the process is easy to use and can process data effectively, without any issue.
Kickstart Your Career
Get certified by completing the courseGet Started