Sheet number variable

  • Thread starter Thread starter mikey10
  • Start date Start date
M

mikey10

Thanks for responding Deepak Agarwal


Basically, to select say sheet 3 in a macro I would write:

Sheets("Sheet3").Select

But say the sheet number is actually a variable called 'Count'.

I need to be able to select the sheet of number 'Count'.
ie. If 'Count' = 5, then I need a macro that selects sheet 5.

Hope this makes more sense,

Thanks for your help,

Mik
 
Have you tried:

Sheets(Count).Select

Count must be an integer, greater than or equal to 1 and less then or equal
to activeworkbook.sheets.count
 
Hi

I think I am getting at what you are after!

Try this :-

Presuming that the variable containing the desired sheet number i
'Count' and the value of 'Count' now is say 3 - hence your macro shoul
select the 3rd worksheet in your workbook an name it as 'Week3', the
this would perhaps help :-

Worksheets(Count).select
activesheet.name = "Week" & Count


This will select the 3rd worksheet in the workbook starting from th
first worksheet beginning from left.

See if this helps - otherwise let me know and I will see if I can offe
further assitance.


Best regards


Deepak Agarwa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top