Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multipage, can commandbutton select Page2? 1

Status
Not open for further replies.

rlee16

Technical User
Jan 19, 2003
44
0
0
HK
I would like to have a command button on my excel worksheet be able to open up a Userform and jump right to a specific page(in this case, Page2) within a MultiPage. Is this possible or do I have to make a brand new Userform?

Regards,

Richard
 

This is similar to the question in thread707-669091

 
Clarification - I have several command buttons on my excel worksheet, each corresponding to a different page on the Multipage

Thread707-669091 seems to only describe setting the focus once.

I would like my command buttons to be able to jump to any of the pages.

Private Sub CommandButton1_Click()
UserForm1.Show (0)
MultiPage1.Pages(2).Visible = True

End Sub

Regards,

Richard
 
Ignore my earlier post. There is an easier way.

Put this code in the sheet code page:
[blue]
Code:
Option Explicit

Private Sub CommandButton1_Click()
  ShowMyForm Page:=1
End Sub

Private Sub CommandButton2_Click()
  ShowMyForm Page:=2
End Sub

Private Sub CommandButton3_Click()
  ShowMyForm Page:=3
End Sub

'(etc.)
[/color]

Put this code in a separate code module:
[blue]
Code:
Option Explicit
Public MultiPageNumber As Integer

Sub ShowMyForm(Page As Integer)
  MultiPageNumber = Page
  UserForm1.Show
End Sub
[/color]

Finally, put this code in the form code page:
[blue]
Code:
Option Explicit

Private Sub UserForm_Initialize()
  MultiPage1.Value = MultiPageNumber - 1
End Sub

Private Sub CommandButton1_Click()
  Me.Hide
End Sub
[/color]

 
Zathas,

Works perfectly! Thank you.

Richard
 
Zathas,

Using this method, is there a way I can I preserve the ability to click into the worksheet functionally equivalent to "Userform1.Show (0)". Thanks.

Richard
 
I'm sorry, I don't understand the question.

In any event, I'm currently on holiday, so perhaps you should post the question in a new thread. (But change the wording and give more explanation. I don't think I'm the only one who wouldn't be able to decypher your request.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top