![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 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! |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Dim sh As Worksheet For Each sh In ActiveWorkbook.Sheets sh.Activate 'do your stuff Next sh HTH Ivan |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 2
|
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!! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|