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
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,216
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,216
Office Version
  1. 365
Platform
  1. Windows
If you just want to activate the previous sheet.
Code:
ActiveSheet.Previous.Activate
 

Watch MrExcel Video

Forum statistics

Threads
1,122,224
Messages
5,594,916
Members
413,952
Latest member
JGer

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