Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Next Worksheet in code
Basic vba question.
How do I go to the next worksheet using code? -- Thanks for your help! Gary S |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Next Worksheet in code
Worksheets(ActiveSheet.Index+1).Activate
"Gary S" wrote: Basic vba question. How do I go to the next worksheet using code? -- Thanks for your help! Gary S |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Next Worksheet in code
Sub ActivateNextSheet()
Dim index As Integer index = ActiveSheet.index If index < Sheets.Count Then Sheets(index + 1).Activate Else Sheets(1).Activate End If End Sub HTH -- AP "Gary S" a écrit dans le message de news: ... Basic vba question. How do I go to the next worksheet using code? -- Thanks for your help! Gary S |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Next Worksheet in code
Or
ActiveSheet.Next.Select Be sure that the last sheet is not active when you run the code -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Smallweed" wrote in message ... Worksheets(ActiveSheet.Index+1).Activate "Gary S" wrote: Basic vba question. How do I go to the next worksheet using code? -- Thanks for your help! Gary S |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Next Worksheet in code
Your subroutine can be reduced to this one-liner...
Sub ActivateNextSheet() Sheets(1 + (Sheets.Count + ActiveSheet.Index) Mod 3).Activate End Sub Rick "Ardus Petus" wrote in message ... Sub ActivateNextSheet() Dim index As Integer index = ActiveSheet.index If index < Sheets.Count Then Sheets(index + 1).Activate Else Sheets(1).Activate End If End Sub HTH -- AP "Gary S" a écrit dans le message de news: ... Basic vba question. How do I go to the next worksheet using code? -- Thanks for your help! Gary S |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Next Worksheet in code
Or this (active sheet wraps at last sheet back to first sheet)...
Sheets(1 + (Sheets.Count + ActiveSheet.Index) Mod 3).Select Rick "Ron de Bruin" wrote in message ... Or ActiveSheet.Next.Select Be sure that the last sheet is not active when you run the code -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Smallweed" wrote in message ... Worksheets(ActiveSheet.Index+1).Activate "Gary S" wrote: Basic vba question. How do I go to the next worksheet using code? -- Thanks for your help! Gary S |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to prevent code running when in a worksheet code | Excel Programming | |||
Code Conflicts With Worksheet Change Code | Excel Programming | |||
Create a newworksheet with VBA code and put VBA code in the new worksheet module | Excel Programming | |||
Altering code to reference the worksheet before the active worksheet | Excel Programming | |||
Return to previous worksheet after code pastes in another worksheet? | Excel Programming |