Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Create Next and Previous Buttons on Userform

Hi guys,
Thx a lot for all your help over the past months!!

I have an userform, and I would like to create 2 commandbuttons tha
will allow the user to move from one worksheet to the next and th
other to move from one worksheet to the previous and when the last o
first worksheet is reached to keep going in circles.

i.e. if user reaches last worksheet and clicks Next to go back to firs
worksheet.

I have a total of 9 worksheets, is that is important.

This is probably the easiest problem to solve, I'm sure.

- Larry -
VBA Amateu

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create Next and Previous Buttons on Userform

if activeSheet.Index = Sheets.count then
Sheets(1).Activate
else
sheets.Next.Activate
End if


if activeSheet.Index = 1 then
Sheets(Sheets.count).Activate
else
sheets.Previous.Activate
End if


--
Regards,
Tom Ogilvy


"nrage21 " wrote in message
...
Hi guys,
Thx a lot for all your help over the past months!!

I have an userform, and I would like to create 2 commandbuttons that
will allow the user to move from one worksheet to the next and the
other to move from one worksheet to the previous and when the last or
first worksheet is reached to keep going in circles.

i.e. if user reaches last worksheet and clicks Next to go back to first
worksheet.

I have a total of 9 worksheets, is that is important.

This is probably the easiest problem to solve, I'm sure.

- Larry -
VBA Amateur


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Create Next and Previous Buttons on Userform

Hi nrage21,

I have an userform, and I would like to create 2 commandbuttons that
will allow the user to move from one worksheet to the next and the
other to move from one worksheet to the previous and when the last or
first worksheet is reached to keep going in circles.

i.e. if user reaches last worksheet and clicks Next to go back to
first worksheet.


Something like this should work:

Private Sub cmdPrevious_Click()
If ActiveSheet.Index = 1 Then
Sheets(Sheets.Count).Activate
Else
Sheets(ActiveSheet.Index - 1).Activate
End If
End Sub

Private Sub cmdNext_Click()
If ActiveSheet.Index = Sheets.Count Then
Sheets(1).Activate
Else
Sheets(ActiveSheet.Index + 1).Activate
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Create Next and Previous Buttons on Userform

Thanks for the quick replies guys!

(Tom: now I can put the comments to a face... I saw a picture of yo
and Chip in Chip Pearson Site... "gentle faces")

:)


- Larry -
VBA Amateu

--
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
buttons and boxes in userform Larry Sartoris Excel Discussion (Misc queries) 3 January 20th 06 04:39 PM
Excel print preview next and previous buttons seem to be backwards Unitrip Excel Discussion (Misc queries) 1 March 27th 05 02:53 PM
Display first, next, previous on userform from recordset Dennis Excel Programming 1 May 24th 04 04:09 AM
Naming buttons in Userform on the fly Richard Excel Programming 1 May 17th 04 08:57 AM
How to add textbox/buttons to an UserForm Terence[_2_] Excel Programming 2 August 7th 03 08:56 AM


All times are GMT +1. The time now is 02:07 AM.

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

About Us

"It's about Microsoft Excel"