![]() |
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 |
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/ |
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] |
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 |
All times are GMT +1. The time now is 05:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com