Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to navigate between sheets

Hi all,

I need help to create 2 macro. One that choose the sheet before th
active sheet, and one that choose the sheet after the active sheet
nomatter whats the name of the sheet.
Just navigate to the sheet left of the active sheet, and right of th
active sheet.


Any help is appreciated!!

//Thoma

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Macro to navigate between sheets

Thomas, try this, you can also use Ctrl+ page up and page down on the key
board

Sub goto_next_sheet()
On Error GoTo E
Sheets(ActiveSheet.Index + 1).Select
Exit Sub
E: MsgBox "This Is The Last Sheet"
End Sub

Sub goto_previous_sheet()
On Error GoTo E
Sheets(ActiveSheet.Index - 1).Select
Exit Sub
E: MsgBox "This Is The First Sheet"
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"Jonsson " wrote in message
...
Hi all,

I need help to create 2 macro. One that choose the sheet before the
active sheet, and one that choose the sheet after the active sheet,
nomatter whats the name of the sheet.
Just navigate to the sheet left of the active sheet, and right of the
active sheet.


Any help is appreciated!!

//Thomas


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to navigate between sheets

Hi Jonsson,

here are 2 macros for you

Sub Forward()
Dim idx As Long
idx = ActiveSheet.Index
If idx < ActiveSheet.Parent.Sheets.Count Then
Sheets(idx + 1).Activate
End If
End Sub

Sub Back()
Dim idx As Long
idx = ActiveSheet.Index
If idx 1 Then
Sheets(idx - 1).Activate
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jonsson " wrote in message
...
Hi all,

I need help to create 2 macro. One that choose the sheet before the
active sheet, and one that choose the sheet after the active sheet,
nomatter whats the name of the sheet.
Just navigate to the sheet left of the active sheet, and right of the
active sheet.


Any help is appreciated!!

//Thomas


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to navigate between sheets

If you aren't going to use the built in shortcut keys, it is
Easier to use the built in methods for this

Sub Moveright()
On Error Resume Next
activesheet.Next.Activate
End Sub

sub MoveLeft()
on Error Resume Next
activesheet.Previous.Activate
End Sub

--
Regards,
Tom Ogilvy

"Jonsson " wrote in message
...
Hi all,

I need help to create 2 macro. One that choose the sheet before the
active sheet, and one that choose the sheet after the active sheet,
nomatter whats the name of the sheet.
Just navigate to the sheet left of the active sheet, and right of the
active sheet.


Any help is appreciated!!

//Thomas


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to navigate between sheets

Hi, Bob, Tom and Paul!

Thanks for your reply!!

They all works as I wanted!

//Thoma

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Navigate in a big worksheet Rockbear Excel Discussion (Misc queries) 4 April 18th 08 04:02 PM
Using forms to navigate mdavisfl Excel Discussion (Misc queries) 0 January 3rd 08 05:31 PM
Ctrl+Page Down to navigate sheets TimT Excel Discussion (Misc queries) 1 May 30th 07 02:21 PM
Navigate between worksheets Louise Excel Worksheet Functions 1 October 9th 06 05:27 PM
Use list box to navigate to different sheets... MrAlMackay Excel Programming 6 July 20th 03 02:53 AM


All times are GMT +1. The time now is 01:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"