Select Next Sheet

88MUST50

New Member
Joined
Feb 17, 2002
Messages
2
I want to have my macro select the next sheet in a spreadsheet. I have tried recording the macro with relative references, but it still gives the tab name in the code. (??)

I am doing this within a loop and just want excel do what it needs to on the first sheet, go to the next sheet and start again/loop until finished (about 35 times). How can I get it to go to the next sheet without having to name it??

I apologize if this is a dumb/simple question, but this is Macro stuff is pretty new to me and any advice would be greatly appreciated!! Thanks!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
On 2002-02-18 18:05, 88MUST50 wrote:
I want to have my macro select the next sheet in a spreadsheet. I have tried recording the macro with relative references, but it still gives the tab name in the code. (??)

I am doing this within a loop and just want excel do what it needs to on the first sheet, go to the next sheet and start again/loop until finished (about 35 times). How can I get it to go to the next sheet without having to name it??

I apologize if this is a dumb/simple question, but this is Macro stuff is pretty new to me and any advice would be greatly appreciated!! Thanks!

Number of ways to do this;

Dim sh As Worksheet

For Each sh In ActiveWorkbook.Sheets
sh.Activate

'do your stuff

Next sh



HTH

Ivan
 
Upvote 0
Thanks Ivan!

Unfortunately, I have tried that but would not work for me because of the way I am pulling the data. For example, I am pulling every fifth column from spreadsheet A and placing into spreadsheet B, with every fifth column from A being a new tab in B.

My macro currently goes to spreadsheet A, selects column 1, copies to spreadsheet B sheet1 (which it later renames). I then need spreadsheet B to go to the next tab to accept the information from column 5 on spreadsheet A.

When I apply this formula, I am limited to the spreadsheet that I am in. I don't think I can alternate back and forth or can I??

Please forgive me if this does not make sense! Thanks!!
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,072
Members
448,546
Latest member
KH Consulting

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