Which worksheet is active




















With the following simple VBA code, you can quickly get the active worksheet number as you want, please do as follows:. Activate the worksheet which you want to return its index number. Then press F5 key to run this code, and you will get the index number of current worksheet in a popping message box as following screenshot shown:.

Related articles:. How to quickly insert sheet names in cells in Excel? How to count the number of sheets of a workbook? Note: The other languages of the website are Google-translated. You can use the. We can copy the data from a worksheet it can be the same sheet or a different sheet and paste in the ActiveSheet. The above macro will Activate the Sheet 2. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time.

This page describes all the amazing new features and options that come with our premium templates. You must be logged in to post a comment. In this topic:. As an example, below code could be included in an Excel file with a worksheet called Locations. If your macro would involve more worksheets, you would probably name the variable wsLocations. Returns Nothing if no sheet exists with that name.

In fact any approach that tries to return a worksheet may return Nothing, so you should always check if a valid worksheet was set. ActiveSheet returns the active sheet the sheet on top in the active workbook or active window. Above code shows the use of the default use: Application. If your macro only is to be used in a specific workbook, for example one that it has just opened, use the more specific:. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Returns an object that represents the active sheet the sheet on top in the active workbook or in the specified window or workbook. Returns Nothing if no sheet is active. If you do not specify an object qualifier, this property returns the active sheet in the active workbook.



0コメント

  • 1000 / 1000