Refer to sheet number not name in Macro

Rufus001

New Member
Joined
Apr 6, 2011
Messages
3
Hi There.
Please help.
I have a monthly workbook with sheets named on the basis of the week ending date.
Each month the workbook is copied, reset and used as the basis of the next month with the the last week of month one becoming the first week of month two.
This of course means that the sheet names change every month.
I am trying to automate the process so the users dont have to think too much (or have the oportunity to muck it up), but dont know how to refer to the sheets other than using their names.
This wont work as they change all the time!
In a Macro can I refer to sheets by their position rather than name?
Hope this makes sense.
Any help is appreciated.
Thanks
Rufus
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
:eeek: OMG - that simple!!

Sometimes it's the simple things in life that make you smile. :biggrin:

Thanks for pointing it out to me - no-one else has yet, Maybe it was just too obvious?

Anyway - thanks again

Rufus
 
Upvote 0
I'd give Lenze's CodeName suggestion a thought, especially with an end-user application. You don't want your code breaking because someone wanted to move a sheet.

(Heya buddy!)
 
Upvote 0
Thanks Guy's

I have gone with Lenze's suggestion and used the CodeName, which works perfectly in my testing - now we have to see when the users ger hold of it.

Although I dont think that they will change the order of the sheets, you just dont know and its best to be safe rather than sorry......

Thanks again.

Rufus
 
Upvote 0
BTW, a smart user can change the CodeName, but I doubt your end-users fall into that category!!! LOL :biggrin:

lenze
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

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
Back
Top