ActiveSheet properties

PapaSmurf

Board Regular
Joined
Nov 4, 2005
Messages
105
I am trying to get the number of the active sheet.
eg.
Activesheet.name would produce "Sheet2"

I just want the number of the sheet so that i can select the previous sheet using;
Sheets(1). select

Thanks
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
I'm not 100% sure what you mean but you can get the sheets's index like this.
Code:
ActiveSheet.Index
and you can get it's code name like this
Code:
ActiveSheet.CodeName
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hi PapaSmurf, welcome to the board!

How about this for selecting the previous sheet ...

Code:
On Error Resume Next
Sheets(ActiveSheet.Index - 1).Activate

You would need the On Error Resume Next statement if you were on sheets(1) when you ran this code. You could make it so that it would loop to the last sheet, and vice versa with the last sheet going to the first. If you'd like ..
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
If you just want to activate the previous sheet.
Code:
ActiveSheet.Previous.Activate
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,984
Messages
5,834,710
Members
430,311
Latest member
JAC0617

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top